diff --git a/src/.gradle/8.0/executionHistory/executionHistory.bin b/src/.gradle/8.0/executionHistory/executionHistory.bin index 424e2a08..4a644d72 100644 Binary files a/src/.gradle/8.0/executionHistory/executionHistory.bin and b/src/.gradle/8.0/executionHistory/executionHistory.bin differ diff --git a/src/.gradle/8.0/executionHistory/executionHistory.lock b/src/.gradle/8.0/executionHistory/executionHistory.lock index 8553cba5..f51dba7e 100644 Binary files a/src/.gradle/8.0/executionHistory/executionHistory.lock and b/src/.gradle/8.0/executionHistory/executionHistory.lock differ diff --git a/src/.gradle/8.0/fileHashes/fileHashes.bin b/src/.gradle/8.0/fileHashes/fileHashes.bin index 7aa0fd55..75361a57 100644 Binary files a/src/.gradle/8.0/fileHashes/fileHashes.bin and b/src/.gradle/8.0/fileHashes/fileHashes.bin differ diff --git a/src/.gradle/8.0/fileHashes/fileHashes.lock b/src/.gradle/8.0/fileHashes/fileHashes.lock index 3926ce52..4546e3d2 100644 Binary files a/src/.gradle/8.0/fileHashes/fileHashes.lock and b/src/.gradle/8.0/fileHashes/fileHashes.lock differ diff --git a/src/.gradle/8.0/fileHashes/resourceHashesCache.bin b/src/.gradle/8.0/fileHashes/resourceHashesCache.bin index 2b406c99..03657ed4 100644 Binary files a/src/.gradle/8.0/fileHashes/resourceHashesCache.bin and b/src/.gradle/8.0/fileHashes/resourceHashesCache.bin differ diff --git a/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock index 7fd91dec..38f3e15b 100644 Binary files a/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/src/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/src/.gradle/file-system.probe b/src/.gradle/file-system.probe index 1641abbb..4a8eff7c 100644 Binary files a/src/.gradle/file-system.probe and b/src/.gradle/file-system.probe differ diff --git a/src/app/build/intermediates/apk/debug/app-debug.apk b/src/app/build/intermediates/apk/debug/app-debug.apk index d948bcb8..545f3b2a 100644 Binary files a/src/app/build/intermediates/apk/debug/app-debug.apk and b/src/app/build/intermediates/apk/debug/app-debug.apk differ diff --git a/src/app/build/intermediates/compile_app_classes_jar/debug/classes.jar b/src/app/build/intermediates/compile_app_classes_jar/debug/classes.jar index 097f3466..0d702100 100644 Binary files a/src/app/build/intermediates/compile_app_classes_jar/debug/classes.jar and b/src/app/build/intermediates/compile_app_classes_jar/debug/classes.jar differ diff --git a/src/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex b/src/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex index 7b6b5c7a..99b9ea16 100644 Binary files a/src/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex and b/src/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex differ diff --git a/src/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt b/src/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt index 9d01008e..54097d1b 100644 --- a/src/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt +++ b/src/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt @@ -1,4 +1,4 @@ -#Mon Dec 18 20:43:44 CST 2023 +#Mon Dec 18 23:30:33 CST 2023 base.0=C\:\\Users\\huigenb\\Desktop\\All tasks\\software\\Notes-master\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex path.0=classes.dex renamed.0=classes.dex diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$1.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$1.class index 5416cd38..d8407fc7 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$1.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$1.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$2.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$2.class index 6efe55fe..1372673e 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$2.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$2.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$3.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$3.class index f8758f37..ac3e1c57 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$3.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity$3.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity.class index c7af5e52..7f5e3510 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditActivity.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText$1.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText$1.class index 2040186e..15c7a9c0 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText$1.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText$1.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText.class index 3a19d3b0..ee9a86c1 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NoteEditText.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$1.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$1.class index f1ba2200..00800378 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$1.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$1.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$2.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$2.class index 76c0c9de..b0069b0c 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$2.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$2.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$3.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$3.class index ae5d23bc..4902bcb9 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$3.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$3.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$4.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$4.class index 62b7e431..a588f420 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$4.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$4.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$5.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$5.class index 0c3614ba..e5ccbce8 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$5.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$5.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$6.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$6.class index 708e26c4..e86fb561 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$6.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$6.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$7.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$7.class index 3adfefed..b8b128bd 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$7.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$7.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class index 003aae65..422f8e22 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$8.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$9.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$9.class index e7be3591..f3f92f74 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$9.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$9.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.class index 127437ff..e8d00387 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$1.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$1.class index 3981f169..7978c300 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$1.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$1.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$2.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$2.class index 99e161f8..a0469f27 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$2.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback$2.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback.class index f249e333..720b2852 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$ModeCallback.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.class index 81f06d33..57091a78 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class index c8bc735d..54153aa3 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class index 8dc90586..bc253a69 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListActivity.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListAdapter.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListAdapter.class index 5e432e90..a6d885ca 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListAdapter.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListAdapter.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListItem.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListItem.class index 45968346..8777b108 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListItem.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesListItem.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$1.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$1.class index 362fa059..046edf1b 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$1.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$1.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$2.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$2.class index 85232285..d0e88bba 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$2.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$2.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$3.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$3.class index d91bc851..15153eb8 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$3.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$3.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$4.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$4.class index 99c7a64f..3439eb90 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$4.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$4.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$5.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$5.class index 17e4d3bb..de07b650 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$5.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$5.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$6.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$6.class index 7b800360..55f86ace 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$6.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$6.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$7.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$7.class index d9abeb93..959e2f99 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$7.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$7.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$8.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$8.class index 39e534ac..9809acc5 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$8.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$8.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.class index eb938cfd..ce7d2739 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.class differ diff --git a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity.class b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity.class index 0937be27..a31b31cb 100644 Binary files a/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity.class and b/src/app/build/intermediates/javac/debug/classes/net/micode/notes/ui/NotesPreferenceActivity.class differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$1.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$1.dex index 1edfd0a8..1342472c 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$1.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$1.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$2.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$2.dex index b3ef6456..8181aa83 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$2.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$2.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$3.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$3.dex index 281f990e..1b2b8e9a 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$3.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity$3.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity.dex index 5edfc87b..9aa23ad2 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditActivity.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText$1.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText$1.dex index 59153307..d675b18c 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText$1.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText$1.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText.dex index 70d2682f..cab36a8a 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NoteEditText.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$1.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$1.dex index c95399db..90748f7b 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$1.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$1.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$2.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$2.dex index 79c670f2..81b2e00f 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$2.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$2.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$3.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$3.dex index 5e89704b..2d33925f 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$3.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$3.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$4.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$4.dex index a97d10b9..b6b9a182 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$4.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$4.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$5.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$5.dex index 2ab53856..db22c954 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$5.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$5.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$6.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$6.dex index 006a084e..a09fa48e 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$6.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$6.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$7.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$7.dex index 4335f4f9..ceaca3f1 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$7.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$7.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex index 99c2d6f1..93b7a049 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$8.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$9.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$9.dex index 36aed4df..6ed3917c 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$9.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$9.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.dex index 2b33a923..7edd2ed9 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$BackgroundQueryHandler.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$1.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$1.dex index 5be9167a..edc9fa7f 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$1.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$1.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$2.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$2.dex index a062b8dd..e10111f2 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$2.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback$2.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback.dex index 9463e101..1ecca762 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$ModeCallback.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.dex index dff3aea3..bb5cdca2 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$NewNoteOnTouchListener.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex index ae574777..903f51ae 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity$OnListItemClickListener.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex index a2905fc0..7e09bedc 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListActivity.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListAdapter.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListAdapter.dex index 68f5579c..6247024c 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListAdapter.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListAdapter.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListItem.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListItem.dex index e5b839dc..5641b4dd 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListItem.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesListItem.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$1.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$1.dex index 14d6a26b..ff5fb97b 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$1.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$1.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$2.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$2.dex index 99e75dd6..aa756cc4 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$2.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$2.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$3.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$3.dex index 80233e5c..f6bec612 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$3.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$3.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$4.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$4.dex index 5919360f..66b2438a 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$4.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$4.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$5.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$5.dex index a5a02afb..1b14ff32 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$5.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$5.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$6.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$6.dex index 194cc494..29992d12 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$6.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$6.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$7.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$7.dex index 48610141..19dbf669 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$7.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$7.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$8.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$8.dex index 5e41302d..350097f4 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$8.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$8.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.dex index 8f2b93dd..a1224e45 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity$GTaskReceiver.dex differ diff --git a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity.dex b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity.dex index 4403885f..be4d7fee 100644 Binary files a/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity.dex and b/src/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/ui/NotesPreferenceActivity.dex differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/AlarmAlertActivity.class.uniqueId44 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/AlarmAlertActivity.class.uniqueId44 new file mode 100644 index 00000000..98353eb0 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/AlarmAlertActivity.class.uniqueId44 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/DataUtils.class.uniqueId39 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/DataUtils.class.uniqueId39 new file mode 100644 index 00000000..5a5386f1 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/DataUtils.class.uniqueId39 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask$1.class.uniqueId1 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask$1.class.uniqueId1 new file mode 100644 index 00000000..520d1dad Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask$1.class.uniqueId1 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask$OnCompleteListener.class.uniqueId6 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask$OnCompleteListener.class.uniqueId6 new file mode 100644 index 00000000..f73069cb Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask$OnCompleteListener.class.uniqueId6 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask.class.uniqueId17 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask.class.uniqueId17 new file mode 100644 index 00000000..dea216da Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskASyncTask.class.uniqueId17 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskClient.class.uniqueId29 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskClient.class.uniqueId29 new file mode 100644 index 00000000..7be3b8a5 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskClient.class.uniqueId29 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskManager.class.uniqueId47 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskManager.class.uniqueId47 new file mode 100644 index 00000000..ac1834cc Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GTaskManager.class.uniqueId47 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$1.class.uniqueId36 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$1.class.uniqueId36 new file mode 100644 index 00000000..5416cd38 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$1.class.uniqueId36 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$2.class.uniqueId8 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$2.class.uniqueId8 new file mode 100644 index 00000000..6efe55fe Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$2.class.uniqueId8 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$3.class.uniqueId22 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$3.class.uniqueId22 new file mode 100644 index 00000000..f8758f37 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$3.class.uniqueId22 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$HeadViewHolder.class.uniqueId49 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$HeadViewHolder.class.uniqueId49 new file mode 100644 index 00000000..8e1f0bf9 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity$HeadViewHolder.class.uniqueId49 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity.class.uniqueId5 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity.class.uniqueId5 new file mode 100644 index 00000000..c7af5e52 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditActivity.class.uniqueId5 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText$1.class.uniqueId13 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText$1.class.uniqueId13 new file mode 100644 index 00000000..2040186e Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText$1.class.uniqueId13 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText$OnTextViewChangeListener.class.uniqueId50 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText$OnTextViewChangeListener.class.uniqueId50 new file mode 100644 index 00000000..9874f47b Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText$OnTextViewChangeListener.class.uniqueId50 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText.class.uniqueId27 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText.class.uniqueId27 new file mode 100644 index 00000000..3a19d3b0 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteEditText.class.uniqueId27 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteItemData.class.uniqueId24 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteItemData.class.uniqueId24 new file mode 100644 index 00000000..771aa912 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteItemData.class.uniqueId24 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteWidgetProvider.class.uniqueId16 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteWidgetProvider.class.uniqueId16 new file mode 100644 index 00000000..a00281f2 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NoteWidgetProvider.class.uniqueId16 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$1.class.uniqueId10 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$1.class.uniqueId10 new file mode 100644 index 00000000..f1ba2200 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$1.class.uniqueId10 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$2.class.uniqueId41 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$2.class.uniqueId41 new file mode 100644 index 00000000..76c0c9de Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$2.class.uniqueId41 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$3.class.uniqueId31 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$3.class.uniqueId31 new file mode 100644 index 00000000..ae5d23bc Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$3.class.uniqueId31 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$4.class.uniqueId18 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$4.class.uniqueId18 new file mode 100644 index 00000000..62b7e431 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$4.class.uniqueId18 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$5.class.uniqueId45 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$5.class.uniqueId45 new file mode 100644 index 00000000..0c3614ba Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$5.class.uniqueId45 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$6.class.uniqueId37 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$6.class.uniqueId37 new file mode 100644 index 00000000..708e26c4 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$6.class.uniqueId37 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$7.class.uniqueId35 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$7.class.uniqueId35 new file mode 100644 index 00000000..3adfefed Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$7.class.uniqueId35 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$8.class.uniqueId48 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$8.class.uniqueId48 new file mode 100644 index 00000000..003aae65 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$8.class.uniqueId48 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$9.class.uniqueId14 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$9.class.uniqueId14 new file mode 100644 index 00000000..e7be3591 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$9.class.uniqueId14 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$BackgroundQueryHandler.class.uniqueId26 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$BackgroundQueryHandler.class.uniqueId26 new file mode 100644 index 00000000..127437ff Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$BackgroundQueryHandler.class.uniqueId26 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ListEditState.class.uniqueId25 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ListEditState.class.uniqueId25 new file mode 100644 index 00000000..2edab7b3 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ListEditState.class.uniqueId25 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback$1.class.uniqueId46 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback$1.class.uniqueId46 new file mode 100644 index 00000000..3981f169 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback$1.class.uniqueId46 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback$2.class.uniqueId19 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback$2.class.uniqueId19 new file mode 100644 index 00000000..99e161f8 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback$2.class.uniqueId19 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback.class.uniqueId7 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback.class.uniqueId7 new file mode 100644 index 00000000..f249e333 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$ModeCallback.class.uniqueId7 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$NewNoteOnTouchListener.class.uniqueId20 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$NewNoteOnTouchListener.class.uniqueId20 new file mode 100644 index 00000000..81f06d33 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$NewNoteOnTouchListener.class.uniqueId20 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$OnListItemClickListener.class.uniqueId40 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$OnListItemClickListener.class.uniqueId40 new file mode 100644 index 00000000..c8bc735d Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity$OnListItemClickListener.class.uniqueId40 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity.class.uniqueId11 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity.class.uniqueId11 new file mode 100644 index 00000000..8dc90586 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListActivity.class.uniqueId11 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListAdapter$AppWidgetAttribute.class.uniqueId51 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListAdapter$AppWidgetAttribute.class.uniqueId51 new file mode 100644 index 00000000..2bdb58bc Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListAdapter$AppWidgetAttribute.class.uniqueId51 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListAdapter.class.uniqueId12 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListAdapter.class.uniqueId12 new file mode 100644 index 00000000..5e432e90 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListAdapter.class.uniqueId12 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListItem.class.uniqueId23 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListItem.class.uniqueId23 new file mode 100644 index 00000000..45968346 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesListItem.class.uniqueId23 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$1.class.uniqueId42 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$1.class.uniqueId42 new file mode 100644 index 00000000..362fa059 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$1.class.uniqueId42 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$2.class.uniqueId30 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$2.class.uniqueId30 new file mode 100644 index 00000000..85232285 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$2.class.uniqueId30 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$3.class.uniqueId15 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$3.class.uniqueId15 new file mode 100644 index 00000000..d91bc851 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$3.class.uniqueId15 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$4.class.uniqueId43 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$4.class.uniqueId43 new file mode 100644 index 00000000..99c7a64f Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$4.class.uniqueId43 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$5.class.uniqueId33 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$5.class.uniqueId33 new file mode 100644 index 00000000..17e4d3bb Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$5.class.uniqueId33 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$6.class.uniqueId21 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$6.class.uniqueId21 new file mode 100644 index 00000000..7b800360 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$6.class.uniqueId21 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$7.class.uniqueId0 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$7.class.uniqueId0 new file mode 100644 index 00000000..d9abeb93 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$7.class.uniqueId0 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$8.class.uniqueId38 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$8.class.uniqueId38 new file mode 100644 index 00000000..39e534ac Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$8.class.uniqueId38 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$GTaskReceiver.class.uniqueId3 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$GTaskReceiver.class.uniqueId3 new file mode 100644 index 00000000..eb938cfd Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity$GTaskReceiver.class.uniqueId3 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity.class.uniqueId9 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity.class.uniqueId9 new file mode 100644 index 00000000..0937be27 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/NotesPreferenceActivity.class.uniqueId9 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$NoteBgResources.class.uniqueId34 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$NoteBgResources.class.uniqueId34 new file mode 100644 index 00000000..84e57a4f Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$NoteBgResources.class.uniqueId34 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$NoteItemBgResources.class.uniqueId2 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$NoteItemBgResources.class.uniqueId2 new file mode 100644 index 00000000..8805a063 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$NoteItemBgResources.class.uniqueId2 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$TextAppearanceResources.class.uniqueId32 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$TextAppearanceResources.class.uniqueId32 new file mode 100644 index 00000000..7f2eb75f Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$TextAppearanceResources.class.uniqueId32 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$WidgetBgResources.class.uniqueId4 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$WidgetBgResources.class.uniqueId4 new file mode 100644 index 00000000..b4ec3bab Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser$WidgetBgResources.class.uniqueId4 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser.class.uniqueId28 b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser.class.uniqueId28 new file mode 100644 index 00000000..f2e1b626 Binary files /dev/null and b/src/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/ResourceParser.class.uniqueId28 differ diff --git a/src/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin b/src/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin index e77c9354..082981b8 100644 Binary files a/src/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin and b/src/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin differ diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java index 556b2f75..97a44840 100644 --- a/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java +++ b/src/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java @@ -165,13 +165,18 @@ public class NoteEditActivity extends Activity implements OnClickListener, * Current activity may be killed when the memory is low. Once it is killed, for another time * user load this activity, we should restore the former state */ + @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); + // 恢复之前保存的状态 if (savedInstanceState != null && savedInstanceState.containsKey(Intent.EXTRA_UID)) { + // 构建一个带有 ACTION_VIEW 的 Intent,并传递之前保存的笔记id Intent intent = new Intent(Intent.ACTION_VIEW); intent.putExtra(Intent.EXTRA_UID, savedInstanceState.getLong(Intent.EXTRA_UID)); + // 初始化Activity的工作状态 if (!initActivityState(intent)) { + // 如果初始化失败,则结束当前Activity finish(); return; } @@ -180,30 +185,28 @@ public class NoteEditActivity extends Activity implements OnClickListener, } private boolean initActivityState(Intent intent) { - /** - * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id, - * then jump to the NotesListActivity - */ + // 初始化工作状态 mWorkingNote = null; if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) { + // 如果用户指定了ACTION_VIEW但没有提供id,则跳转到NotesListActivity long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0); mUserQuery = ""; - - /** - * Starting from the searched result - */ + + // 从搜索结果开始 if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) { noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY)); mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY); } - + if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) { + // 如果数据库中不存在指定的笔记,则跳转到NotesListActivity并显示错误信息 Intent jump = new Intent(this, NotesListActivity.class); startActivity(jump); showToast(R.string.error_note_not_exist); finish(); return false; } else { + // 加载指定id的笔记 mWorkingNote = WorkingNote.load(this, noteId); if (mWorkingNote == null) { Log.e(TAG, "load note failed with note id" + noteId); @@ -215,7 +218,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); } else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) { - // New note + // 新建笔记 long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0); int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID); @@ -223,8 +226,8 @@ public class NoteEditActivity extends Activity implements OnClickListener, Notes.TYPE_WIDGET_INVALIDE); int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, ResourceParser.getDefaultBgId(this)); - - // Parse call-record note + + // 解析来电记录笔记 String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0); if (callDate != 0 && phoneNumber != null) { @@ -234,6 +237,7 @@ public class NoteEditActivity extends Activity implements OnClickListener, long noteId = 0; if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(), phoneNumber, callDate)) > 0) { + // 加载指定id的来电记录笔记 mWorkingNote = WorkingNote.load(this, noteId); if (mWorkingNote == null) { Log.e(TAG, "load call note failed with note id" + noteId); @@ -241,307 +245,430 @@ public class NoteEditActivity extends Activity implements OnClickListener, return false; } } else { + // 创建空的来电记录笔记并转换为来电记录 mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId); mWorkingNote.convertToCallNote(phoneNumber, callDate); } } else { + // 创建空的笔记 mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId); } - + getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); } else { + // 如果Intent没有指定操作,则不应该支持该Intent,记录错误并关闭当前Activity Log.e(TAG, "Intent not specified action, should not support"); finish(); return false; } + // 设置工作状态改变监听器并返回true表示初始化成功 mWorkingNote.setOnSettingStatusChangedListener(this); return true; } - @Override - protected void onResume() { - super.onResume(); - initNoteScreen(); +@Override +protected void onResume() { + super.onResume(); + initNoteScreen(); // 初始化笔记界面 +} + +private void initNoteScreen() { + // 设置笔记编辑器的文本外观 + mNoteEditor.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); + + // 根据工作笔记的模式进行不同的处理 + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { + // 如果是清单模式,将编辑器切换到清单模式 + switchToListMode(mWorkingNote.getContent()); + } else { + // 如果不是清单模式,将编辑器的文本设置为工作笔记的内容 + mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery)); + // 将光标设置在文本末尾 + mNoteEditor.setSelection(mNoteEditor.getText().length()); } - private void initNoteScreen() { - mNoteEditor.setTextAppearance(this, TextAppearanceResources - .getTexAppearanceResource(mFontSizeId)); - if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { - switchToListMode(mWorkingNote.getContent()); + // 隐藏背景选择器中当前选中的项 + for (Integer id : sBgSelectorSelectionMap.keySet()) { + findViewById(sBgSelectorSelectionMap.get(id)).setVisibility(View.GONE); + } + + // 设置标题栏的背景资源 + mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId()); + // 设置笔记编辑区域的背景颜色 + mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId()); + + // 设置笔记的修改日期 + mNoteHeaderHolder.tvModified.setText(DateUtils.formatDateTime(this, + mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE + | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME + | DateUtils.FORMAT_SHOW_YEAR)); + + /** + * TODO: Add the menu for setting alert. Currently disable it because the DateTimePicker + * is not ready + */ + showAlertHeader(); // 显示提醒信息(如果有) +} + +private void showAlertHeader() { + // 如果工作笔记设置了提醒 + if (mWorkingNote.hasClockAlert()) { + long time = System.currentTimeMillis(); + if (time > mWorkingNote.getAlertDate()) { + // 如果提醒时间已过期,显示"提醒已过期" + mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired); } else { - mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery)); - mNoteEditor.setSelection(mNoteEditor.getText().length()); - } - for (Integer id : sBgSelectorSelectionMap.keySet()) { - findViewById(sBgSelectorSelectionMap.get(id)).setVisibility(View.GONE); + // 否则,显示距提醒时间的相对时间 + mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString( + mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS)); } - mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId()); - mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId()); + // 显示提醒时间文本和提醒图标 + mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE); + mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE); + } else { + // 如果工作笔记没有设置提醒,隐藏提醒时间文本和提醒图标 + mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE); + mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE); + }; +} - mNoteHeaderHolder.tvModified.setText(DateUtils.formatDateTime(this, - mWorkingNote.getModifiedDate(), DateUtils.FORMAT_SHOW_DATE - | DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_SHOW_TIME - | DateUtils.FORMAT_SHOW_YEAR)); - /** - * TODO: Add the menu for setting alert. Currently disable it because the DateTimePicker - * is not ready - */ - showAlertHeader(); - } - private void showAlertHeader() { - if (mWorkingNote.hasClockAlert()) { - long time = System.currentTimeMillis(); - if (time > mWorkingNote.getAlertDate()) { - mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired); - } else { - mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString( - mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS)); - } - mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE); - mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE); - } else { - mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE); - mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE); - }; - } +@Override +protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + initActivityState(intent); +} - @Override - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - initActivityState(intent); +@Override +protected void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + + /** + * 如果编辑的笔记尚未在数据库中存在(没有ID),我们先保存它以生成一个ID。 + * 如果正在编辑的笔记不值得保存,则没有ID等同于创建新的笔记。 + */ + if (!mWorkingNote.existInDatabase()) { + saveNote(); } + + outState.putLong(Intent.EXTRA_UID, mWorkingNote.getNoteId()); + Log.d(TAG, "保存正在编辑的笔记ID:" + mWorkingNote.getNoteId() + ",onSaveInstanceState"); +} - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - /** - * For new note without note id, we should firstly save it to - * generate a id. If the editing note is not worth saving, there - * is no id which is equivalent to create new note - */ - if (!mWorkingNote.existInDatabase()) { - saveNote(); - } - outState.putLong(Intent.EXTRA_UID, mWorkingNote.getNoteId()); - Log.d(TAG, "Save working note id: " + mWorkingNote.getNoteId() + " onSaveInstanceState"); +@Override +public boolean dispatchTouchEvent(MotionEvent ev) { + // 如果笔记背景颜色选择器可见,并且触摸事件的位置不在选择器内,隐藏选择器并返回true + if (mNoteBgColorSelector.getVisibility() == View.VISIBLE + && !inRangeOfView(mNoteBgColorSelector, ev)) { + mNoteBgColorSelector.setVisibility(View.GONE); + return true; } - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - if (mNoteBgColorSelector.getVisibility() == View.VISIBLE - && !inRangeOfView(mNoteBgColorSelector, ev)) { - mNoteBgColorSelector.setVisibility(View.GONE); - return true; - } - - if (mFontSizeSelector.getVisibility() == View.VISIBLE - && !inRangeOfView(mFontSizeSelector, ev)) { - mFontSizeSelector.setVisibility(View.GONE); - return true; - } - return super.dispatchTouchEvent(ev); - } - - private boolean inRangeOfView(View view, MotionEvent ev) { - int []location = new int[2]; - view.getLocationOnScreen(location); - int x = location[0]; - int y = location[1]; - if (ev.getX() < x - || ev.getX() > (x + view.getWidth()) - || ev.getY() < y - || ev.getY() > (y + view.getHeight())) { - return false; - } + // 如果字体大小选择器可见,并且触摸事件的位置不在选择器内,隐藏选择器并返回true + if (mFontSizeSelector.getVisibility() == View.VISIBLE + && !inRangeOfView(mFontSizeSelector, ev)) { + mFontSizeSelector.setVisibility(View.GONE); return true; } + + // 如果触摸事件位置没有被处理,则调用父类的dispatchTouchEvent方法处理事件 + return super.dispatchTouchEvent(ev); +} - private void initResources() { - mHeadViewPanel = findViewById(R.id.note_title); - mNoteHeaderHolder = new HeadViewHolder(); - mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date); - mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon); - mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date); - mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color); - mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this); - mNoteEditor = (EditText) findViewById(R.id.note_edit_view); - mNoteEditorPanel = findViewById(R.id.sv_note_edit); - mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector); - for (int id : sBgSelectorBtnsMap.keySet()) { - ImageView iv = (ImageView) findViewById(id); - iv.setOnClickListener(this); - } +/** + * 检查触摸事件的位置是否在给定View内部 + * + * @param view 要检查的View + * @param ev 触摸事件 + * @return 触摸事件位置是否在View内部 + */ +private boolean inRangeOfView(View view, MotionEvent ev) { + int[] location = new int[2]; + view.getLocationOnScreen(location); + int x = location[0]; + int y = location[1]; + + // 如果触摸事件的位置超出了View的边界,则返回false + if (ev.getX() < x + || ev.getX() > (x + view.getWidth()) + || ev.getY() < y + || ev.getY() > (y + view.getHeight())) { + return false; + } + + return true; +} - mFontSizeSelector = findViewById(R.id.font_size_selector); - for (int id : sFontSizeBtnsMap.keySet()) { - View view = findViewById(id); - view.setOnClickListener(this); - }; - mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); - mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE); - /** - * HACKME: Fix bug of store the resource id in shared preference. - * The id may larger than the length of resources, in this case, - * return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE} - */ - if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) { - mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE; - } - mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list); +private void initResources() { + // 初始化控件和资源 + + // 获取布局中的note_title并赋值给mHeadViewPanel + mHeadViewPanel = findViewById(R.id.note_title); + + // 创建HeadViewHolder实例 + mNoteHeaderHolder = new HeadViewHolder(); + // 获取布局中的tv_modified_date并赋值给mNoteHeaderHolder中的tvModified + mNoteHeaderHolder.tvModified = (TextView) findViewById(R.id.tv_modified_date); + // 获取布局中的iv_alert_icon并赋值给mNoteHeaderHolder中的ivAlertIcon + mNoteHeaderHolder.ivAlertIcon = (ImageView) findViewById(R.id.iv_alert_icon); + // 获取布局中的tv_alert_date并赋值给mNoteHeaderHolder中的tvAlertDate + mNoteHeaderHolder.tvAlertDate = (TextView) findViewById(R.id.tv_alert_date); + // 获取布局中的btn_set_bg_color并赋值给mNoteHeaderHolder中的ibSetBgColor + mNoteHeaderHolder.ibSetBgColor = (ImageView) findViewById(R.id.btn_set_bg_color); + // 设置ibSetBgColor的点击事件监听器为当前Activity(this) + mNoteHeaderHolder.ibSetBgColor.setOnClickListener(this); + + // 获取布局中的note_edit_view并赋值给mNoteEditor + mNoteEditor = (EditText) findViewById(R.id.note_edit_view); + // 获取布局中的sv_note_edit并赋值给mNoteEditorPanel + mNoteEditorPanel = findViewById(R.id.sv_note_edit); + + // 获取布局中的note_bg_color_selector并赋值给mNoteBgColorSelector + mNoteBgColorSelector = findViewById(R.id.note_bg_color_selector); + // 遍历sBgSelectorBtnsMap中的按钮ID,并为每个按钮设置点击事件监听器为当前Activity(this) + for (int id : sBgSelectorBtnsMap.keySet()) { + ImageView iv = (ImageView) findViewById(id); + iv.setOnClickListener(this); } - @Override - protected void onPause() { - super.onPause(); - if(saveNote()) { - Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length()); - } - clearSettingState(); + // 获取布局中的font_size_selector并赋值给mFontSizeSelector + mFontSizeSelector = findViewById(R.id.font_size_selector); + // 遍历sFontSizeBtnsMap中的按钮ID,并为每个按钮设置点击事件监听器为当前Activity(this) + for (int id : sFontSizeBtnsMap.keySet()) { + View view = findViewById(id); + view.setOnClickListener(this); + }; + + // 获取默认的SharedPreferences实例 + mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); + // 从SharedPreferences中获取设置的字体大小ID,默认值为ResourceParser.BG_DEFAULT_FONT_SIZE + mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE); + /** + * HACKME: 修复存储资源ID的共享偏好的bug。 + * ID可能大于资源的长度,在这种情况下, + * 将其设置为ResourceParser.BG_DEFAULT_FONT_SIZE。 + */ + if(mFontSizeId >= TextAppearanceResources.getResourcesSize()) { + mFontSizeId = ResourceParser.BG_DEFAULT_FONT_SIZE; } - private void updateWidget() { - Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); - if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) { - intent.setClass(this, NoteWidgetProvider_2x.class); - } else if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_4X) { - intent.setClass(this, NoteWidgetProvider_4x.class); - } else { - Log.e(TAG, "Unspported widget type"); - return; - } + // 获取布局中的note_edit_list并赋值给mEditTextList + mEditTextList = (LinearLayout) findViewById(R.id.note_edit_list); +} - intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { - mWorkingNote.getWidgetId() - }); +@Override +protected void onPause() { + super.onPause(); + // 当Activity暂停时,保存笔记数据并输出日志 + if(saveNote()) { + Log.d(TAG, "Note data was saved with length:" + mWorkingNote.getContent().length()); + } + // 清除设置状态 + clearSettingState(); +} - sendBroadcast(intent); - setResult(RESULT_OK, intent); - } - - public void onClick(View v) { - int id = v.getId(); - if (id == R.id.btn_set_bg_color) { - mNoteBgColorSelector.setVisibility(View.VISIBLE); - findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( - View.VISIBLE); - } else if (sBgSelectorBtnsMap.containsKey(id)) { - findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( - View.GONE); - mWorkingNote.setBgColorId(sBgSelectorBtnsMap.get(id)); - mNoteBgColorSelector.setVisibility(View.GONE); - } else if (sFontSizeBtnsMap.containsKey(id)) { - findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.GONE); - mFontSizeId = sFontSizeBtnsMap.get(id); - mSharedPrefs.edit().putInt(PREFERENCE_FONT_SIZE, mFontSizeId).commit(); - findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); - if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { - getWorkingText(); - switchToListMode(mWorkingNote.getContent()); - } else { - mNoteEditor.setTextAppearance(this, - TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); - } - mFontSizeSelector.setVisibility(View.GONE); - } +private void updateWidget() { + // 更新小部件 + + // 创建一个更新小部件的意图 + Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); + + // 根据工作笔记的小部件类型设置相应的小部件提供者类 + if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) { + intent.setClass(this, NoteWidgetProvider_2x.class); + } else if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_4X) { + intent.setClass(this, NoteWidgetProvider_4x.class); + } else { + // 不支持的小部件类型,输出错误日志并返回 + Log.e(TAG, "Unspported widget type"); + return; } - @Override - public void onBackPressed() { - if(clearSettingState()) { - return; - } + // 将工作笔记的小部件ID作为额外数据放入意图中 + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { + mWorkingNote.getWidgetId() + }); - saveNote(); - super.onBackPressed(); - } + // 发送广播来更新小部件 + sendBroadcast(intent); + setResult(RESULT_OK, intent); +} - private boolean clearSettingState() { - if (mNoteBgColorSelector.getVisibility() == View.VISIBLE) { - mNoteBgColorSelector.setVisibility(View.GONE); - return true; - } else if (mFontSizeSelector.getVisibility() == View.VISIBLE) { - mFontSizeSelector.setVisibility(View.GONE); - return true; +public void onClick(View v) { + // 获取当前点击的控件的ID + int id = v.getId(); + if (id == R.id.btn_set_bg_color) { + // 如果点击的是设置背景颜色的按钮 + // 显示背景颜色选择器 + mNoteBgColorSelector.setVisibility(View.VISIBLE); + // 显示当前工作笔记背景颜色的选择项 + findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(View.VISIBLE); + } else if (sBgSelectorBtnsMap.containsKey(id)) { + // 如果点击的是背景颜色选择器中的一个按钮 + // 隐藏当前工作笔记背景颜色的选择项 + findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(View.GONE); + // 设置新的背景颜色ID给工作笔记 + mWorkingNote.setBgColorId(sBgSelectorBtnsMap.get(id)); + // 隐藏背景颜色选择器 + mNoteBgColorSelector.setVisibility(View.GONE); + } else if (sFontSizeBtnsMap.containsKey(id)) { + // 如果点击的是字体大小选择器中的一个按钮 + // 隐藏当前字体大小的选择项 + findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.GONE); + // 设置新的字体大小ID + mFontSizeId = sFontSizeBtnsMap.get(id); + // 将新的字体大小ID保存到SharedPreferences中 + mSharedPrefs.edit().putInt(PREFERENCE_FONT_SIZE, mFontSizeId).commit(); + // 显示新的字体大小的选择项 + findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { + // 如果工作笔记是待办事项模式 + // 获取当前工作文本 + getWorkingText(); + // 切换到待办事项模式 + switchToListMode(mWorkingNote.getContent()); + } else { + // 如果工作笔记不是待办事项模式 + // 设置文本编辑框的文本样式为选择的字体大小 + mNoteEditor.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); } - return false; + // 隐藏字体大小选择器 + mFontSizeSelector.setVisibility(View.GONE); } +} - public void onBackgroundColorChanged() { - findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility( - View.VISIBLE); - mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId()); - mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId()); +@Override +public void onBackPressed() { + // 当返回按钮按下时 + if (clearSettingState()) { + // 如果当前状态是设置状态,清除设置状态并返回 + return; } - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - if (isFinishing()) { - return true; - } - clearSettingState(); - menu.clear(); - if (mWorkingNote.getFolderId() == Notes.ID_CALL_RECORD_FOLDER) { - getMenuInflater().inflate(R.menu.call_note_edit, menu); - } else { - getMenuInflater().inflate(R.menu.note_edit, menu); - } - if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { - menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_normal_mode); - } else { - menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_list_mode); - } - if (mWorkingNote.hasClockAlert()) { - menu.findItem(R.id.menu_alert).setVisible(false); - } else { - menu.findItem(R.id.menu_delete_remind).setVisible(false); - } + // 保存工作笔记 + saveNote(); + super.onBackPressed(); +} + +private boolean clearSettingState() { + // 清除设置状态方法 + if (mNoteBgColorSelector.getVisibility() == View.VISIBLE) { + // 如果背景颜色选择器可见 + // 隐藏背景颜色选择器 + mNoteBgColorSelector.setVisibility(View.GONE); + return true; + } else if (mFontSizeSelector.getVisibility() == View.VISIBLE) { + // 如果字体大小选择器可见 + // 隐藏字体大小选择器 + mFontSizeSelector.setVisibility(View.GONE); return true; } + return false; +} - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int itemId = item.getItemId(); - if (itemId == R.id.menu_new_note) { - createNewNote(); - } else if (itemId == R.id.menu_delete) { - AlertDialog.Builder builder = new AlertDialog.Builder(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_note)); - builder.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - deleteCurrentNote(); - finish(); - } - }); - builder.setNegativeButton(android.R.string.cancel, null); - builder.show(); - } else if (itemId == R.id.menu_font_size) { - mFontSizeSelector.setVisibility(View.VISIBLE); - findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); - } else if (itemId == R.id.menu_list_mode) { - mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ? - TextNote.MODE_CHECK_LIST : 0); - } else if (itemId == R.id.menu_share) { - getWorkingText(); - sendTo(this, mWorkingNote.getContent()); - } else if (itemId == R.id.menu_send_to_desktop) { - sendToDesktop(); - } else if (itemId == R.id.menu_alert) { - setReminder(); - } else if (itemId == R.id.menu_delete_remind) { - mWorkingNote.setAlertDate(0, false); - } +public void onBackgroundColorChanged() { + // 根据当前工作笔记的背景颜色ID显示相应的选择项 + findViewById(sBgSelectorSelectionMap.get(mWorkingNote.getBgColorId())).setVisibility(View.VISIBLE); + // 设置工作笔记编辑面板的背景颜色为当前工作笔记的背景颜色资源ID + mNoteEditorPanel.setBackgroundResource(mWorkingNote.getBgColorResId()); + // 设置工作笔记标题栏的背景颜色为当前工作笔记的标题背景资源ID + mHeadViewPanel.setBackgroundResource(mWorkingNote.getTitleBgResId()); +} + +@Override +public boolean onPrepareOptionsMenu(Menu menu) { + // 菜单准备方法,动态显示菜单项 + if (isFinishing()) { return true; } + // 清除设置状态 + clearSettingState(); + // 清空菜单项 + menu.clear(); + if (mWorkingNote.getFolderId() == Notes.ID_CALL_RECORD_FOLDER) { + // 如果工作笔记所在文件夹是通话记录文件夹 + // 加载通话记录编辑菜单 + getMenuInflater().inflate(R.menu.call_note_edit, menu); + } else { + // 加载普通笔记编辑菜单 + getMenuInflater().inflate(R.menu.note_edit, menu); + } + if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) { + // 如果工作笔记是待办事项模式 + // 动态设置菜单项的标题为“普通模式” + menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_normal_mode); + } else { + // 动态设置菜单项的标题为“待办事项模式” + menu.findItem(R.id.menu_list_mode).setTitle(R.string.menu_list_mode); + } + if (mWorkingNote.hasClockAlert()) { + // 如果工作笔记有闹钟提醒 + // 隐藏菜单项“提醒” + menu.findItem(R.id.menu_alert).setVisible(false); + } else { + // 隐藏菜单项“删除提醒” + menu.findItem(R.id.menu_delete_remind).setVisible(false); + } + return true; +} + +@Override +public boolean onOptionsItemSelected(MenuItem item) { + int itemId = item.getItemId(); + if (itemId == R.id.menu_new_note) { + // 当点击菜单项“新建笔记”时 + createNewNote(); + } else if (itemId == R.id.menu_delete) { + // 当点击菜单项“删除笔记”时 + // 弹出确认对话框 + AlertDialog.Builder builder = new AlertDialog.Builder(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_note)); + builder.setPositiveButton(android.R.string.ok, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + // 确认删除工作笔记,删除并结束当前活动 + deleteCurrentNote(); + finish(); + } + }); + builder.setNegativeButton(android.R.string.cancel, null); + builder.show(); + } else if (itemId == R.id.menu_font_size) { + // 当点击菜单项“字体大小”时 + // 显示字体大小选择器,并根据当前字体大小ID显示相应的选择项 + mFontSizeSelector.setVisibility(View.VISIBLE); + findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE); + } else if (itemId == R.id.menu_list_mode) { + // 当点击菜单项“模式切换”时 + // 切换工作笔记的待办事项模式 + mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ? + TextNote.MODE_CHECK_LIST : 0); + } else if (itemId == R.id.menu_share) { + // 当点击菜单项“分享”时 + // 获取当前工作文本并进行分享 + getWorkingText(); + sendTo(this, mWorkingNote.getContent()); + } else if (itemId == R.id.menu_send_to_desktop) { + // 当点击菜单项“发送到桌面”时 + sendToDesktop(); + } else if (itemId == R.id.menu_alert) { + // 当点击菜单项“提醒”时 + // 设置闹钟提醒 + setReminder(); + } else if (itemId == R.id.menu_delete_remind) { + // 当点击菜单项“删除提醒”时 + // 清除工作笔记的提醒日期和提醒标志 + mWorkingNote.setAlertDate(0, false); + } + return true; +} private void setReminder() { /* @@ -643,179 +770,222 @@ public class NoteEditActivity extends Activity implements OnClickListener, */ } - private boolean isSyncMode() { - return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0; - } +// 判断是否为同步模式 +private boolean isSyncMode() { + return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0; +} - public void onClockAlertChanged(long date, boolean set) { - /** - * User could set clock to an unsaved note, so before setting the - * alert clock, we should save the note first - */ - if (!mWorkingNote.existInDatabase()) { - saveNote(); - } - if (mWorkingNote.getNoteId() > 0) { - Intent intent = new Intent(this, AlarmReceiver.class); - intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId())); - PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); - AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE)); - showAlertHeader(); - if(!set) { - alarmManager.cancel(pendingIntent); - } else { - alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent); - } +// 当闹钟提醒设置改变时的处理 +public void onClockAlertChanged(long date, boolean set) { + // 如果当前工作笔记不存在于数据库中,则保存笔记 + if (!mWorkingNote.existInDatabase()) { + saveNote(); + } + // 如果工作笔记的ID大于0,则继续处理 + if (mWorkingNote.getNoteId() > 0) { + // 创建AlarmReceiver的Intent + Intent intent = new Intent(this, AlarmReceiver.class); + intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId())); + // 创建用于广播的PendingIntent + PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0); + // 获取AlarmManager实例 + AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE)); + // 显示提醒标题 + showAlertHeader(); + // 根据set参数判断是否设置或取消闹钟提醒 + if(!set) { + alarmManager.cancel(pendingIntent); // 取消闹钟提醒 } else { - /** - * There is the condition that user has input nothing (the note is - * not worthy saving), we have no note id, remind the user that he - * should input something - */ - Log.e(TAG, "Clock alert setting error"); - showToast(R.string.error_note_empty_for_clock); + alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent); // 设置闹钟提醒 } + } else { + // 如果工作笔记ID小于等于0,记录错误并显示提示 + Log.e(TAG, "Clock alert setting error"); + showToast(R.string.error_note_empty_for_clock); } +} - public void onWidgetChanged() { - updateWidget(); +// 当小部件改变时的处理 +public void onWidgetChanged() { + updateWidget(); // 更新小部件 +} + +// 当文本编辑框内容删除时的处理 +public void onEditTextDelete(int index, String text) { + int childCount = mEditTextList.getChildCount(); + // 如果子View数量为1,则直接返回 + if (childCount == 1) { + return; } - public void onEditTextDelete(int index, String text) { - int childCount = mEditTextList.getChildCount(); - if (childCount == 1) { - return; - } + // 重新设置剩余编辑框的索引 + for (int i = index + 1; i < childCount; i++) { + ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text)).setIndex(i - 1); + } - for (int i = index + 1; i < childCount; i++) { - ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text)) - .setIndex(i - 1); - } + // 移除指定位置的编辑框 + mEditTextList.removeViewAt(index); + NoteEditText edit = null; + // 获取上一个编辑框,如果是第一个则获取第一个编辑框 + if(index == 0) { + edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById(R.id.et_edit_text); + } else { + edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(R.id.et_edit_text); + } + int length = edit.length(); + // 在编辑框末尾添加指定文本 + edit.append(text); + edit.requestFocus(); + edit.setSelection(length); // 设置光标位置 +} - mEditTextList.removeViewAt(index); - NoteEditText edit = null; - if(index == 0) { - edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById( - R.id.et_edit_text); - } else { - edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById( - R.id.et_edit_text); - } - int length = edit.length(); - edit.append(text); - edit.requestFocus(); - edit.setSelection(length); +public void onEditTextEnter(int index, String text) { + /** + * 如果索引超出 mEditTextList 的范围,应该不会发生,进行调试检查 + */ + if(index > mEditTextList.getChildCount()) { + Log.e(TAG, "Index out of mEditTextList boundrary, should not happen"); } - public void onEditTextEnter(int index, String text) { - /** - * Should not happen, check for debug - */ - if(index > mEditTextList.getChildCount()) { - Log.e(TAG, "Index out of mEditTextList boundrary, should not happen"); - } + // 创建新的编辑框视图并添加到 mEditTextList 中指定的位置 + View view = getListItem(text, index); + mEditTextList.addView(view, index); + NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); + edit.requestFocus(); + edit.setSelection(0); + for (int i = index + 1; i < mEditTextList.getChildCount(); i++) { + ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text)) + .setIndex(i); + } +} - View view = getListItem(text, index); - mEditTextList.addView(view, index); - NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); - edit.requestFocus(); - edit.setSelection(0); - for (int i = index + 1; i < mEditTextList.getChildCount(); i++) { - ((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text)) - .setIndex(i); +// 切换到列表模式的处理方法 +private void switchToListMode(String text) { + // 移除所有的编辑框视图 + mEditTextList.removeAllViews(); + // 将文本按换行符分割成字符串数组 + String[] items = text.split("\n"); + int index = 0; + for (String item : items) { + // 如果项不为空,则创建对应的编辑框视图并添加到 mEditTextList 中 + if(!TextUtils.isEmpty(item)) { + mEditTextList.addView(getListItem(item, index)); + index++; } } + // 添加一个空的编辑框以便用户继续添加新项 + mEditTextList.addView(getListItem("", index)); + mEditTextList.getChildAt(index).findViewById(R.id.et_edit_text).requestFocus(); - private void switchToListMode(String text) { - mEditTextList.removeAllViews(); - String[] items = text.split("\n"); - int index = 0; - for (String item : items) { - if(!TextUtils.isEmpty(item)) { - mEditTextList.addView(getListItem(item, index)); - index++; - } + // 隐藏笔记编辑视图,显示编辑框列表视图 + mNoteEditor.setVisibility(View.GONE); + mEditTextList.setVisibility(View.VISIBLE); +} + +// 获取包含用户查询结果高亮的 Spannable 对象 +private Spannable getHighlightQueryResult(String fullText, String userQuery) { + SpannableString spannable = new SpannableString(fullText == null ? "" : fullText); + if (!TextUtils.isEmpty(userQuery)) { + mPattern = Pattern.compile(userQuery); + Matcher m = mPattern.matcher(fullText); + int start = 0; + while (m.find(start)) { + // 对匹配到的文本进行高亮处理 + spannable.setSpan( + new BackgroundColorSpan(this.getResources().getColor( + R.color.user_query_highlight)), m.start(), m.end(), + Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + start = m.end(); } - mEditTextList.addView(getListItem("", index)); - mEditTextList.getChildAt(index).findViewById(R.id.et_edit_text).requestFocus(); - - mNoteEditor.setVisibility(View.GONE); - mEditTextList.setVisibility(View.VISIBLE); - } - - private Spannable getHighlightQueryResult(String fullText, String userQuery) { - SpannableString spannable = new SpannableString(fullText == null ? "" : fullText); - if (!TextUtils.isEmpty(userQuery)) { - mPattern = Pattern.compile(userQuery); - Matcher m = mPattern.matcher(fullText); - int start = 0; - while (m.find(start)) { - spannable.setSpan( - new BackgroundColorSpan(this.getResources().getColor( - R.color.user_query_highlight)), m.start(), m.end(), - Spannable.SPAN_INCLUSIVE_EXCLUSIVE); - start = m.end(); + } + return spannable; +} + +/** + * 通过传入的内容和索引,获取包含编辑框和复选框的列表项视图 + * @param item 列表项内容 + * @param index 列表项索引 + * @return 列表项视图 + */ +private View getListItem(String item, int index) { + // 加载列表项布局 + View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null); + final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); + // 设置文本外观 + edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); + CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item)); + // 设置复选框选中状态变化时的监听器 + cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { + if (isChecked) { + // 文本加上删除线 + edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); + } else { + // 取消文本删除线 + edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); } } - return spannable; - } - - private View getListItem(String item, int index) { - View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null); - final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text); - edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId)); - CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item)); - cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked) { - edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); - } else { - edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); - } - } - }); + }); + + if (item.startsWith(TAG_CHECKED)) { + // 如果列表项以 "checked" 标识开头,则设置复选框选中状态,设置文本删除线,并去掉标识字符串 + cb.setChecked(true); + edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); + item = item.substring(TAG_CHECKED.length(), item.length()).trim(); + } else if (item.startsWith(TAG_UNCHECKED)) { + // 如果列表项以 "unchecked" 标识开头,则设置复选框未选中状态,取消文本删除线,并去掉标识字符串 + cb.setChecked(false); + edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); + item = item.substring(TAG_UNCHECKED.length(), item.length()).trim(); + } - if (item.startsWith(TAG_CHECKED)) { - cb.setChecked(true); - edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); - item = item.substring(TAG_CHECKED.length(), item.length()).trim(); - } else if (item.startsWith(TAG_UNCHECKED)) { - cb.setChecked(false); - edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG); - item = item.substring(TAG_UNCHECKED.length(), item.length()).trim(); - } + edit.setOnTextViewChangeListener(this); + edit.setIndex(index); + // 设置文本,并将用户查询结果高亮显示 + edit.setText(getHighlightQueryResult(item, mUserQuery)); + return view; +} - edit.setOnTextViewChangeListener(this); - edit.setIndex(index); - edit.setText(getHighlightQueryResult(item, mUserQuery)); - return view; +/** + * 当文本内容改变时的回调方法 + * @param index 列表项索引 + * @param hasText 是否有文本内容 + */ +public void onTextChange(int index, boolean hasText) { + if (index >= mEditTextList.getChildCount()) { + Log.e(TAG, "Wrong index, should not happen"); + return; } - - public void onTextChange(int index, boolean hasText) { - if (index >= mEditTextList.getChildCount()) { - Log.e(TAG, "Wrong index, should not happen"); - return; - } - if(hasText) { - mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.VISIBLE); - } else { - mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE); - } + if(hasText) { + // 如果有文本内容,则显示复选框 + mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.VISIBLE); + } else { + // 如果没有文本内容,则隐藏复选框 + mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE); } +} - public void onCheckListModeChanged(int oldMode, int newMode) { - if (newMode == TextNote.MODE_CHECK_LIST) { - switchToListMode(mNoteEditor.getText().toString()); - } else { - if (!getWorkingText()) { - mWorkingNote.setWorkingText(mWorkingNote.getContent().replace(TAG_UNCHECKED + " ", - "")); - } - mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery)); - mEditTextList.setVisibility(View.GONE); - mNoteEditor.setVisibility(View.VISIBLE); +/** + * 当待办事项模式变化时的回调方法 + * @param oldMode 旧的待办事项模式 + * @param newMode 新的待办事项模式 + */ +public void onCheckListModeChanged(int oldMode, int newMode) { + if (newMode == TextNote.MODE_CHECK_LIST) { + // 如果新的模式是待办事项列表模式,则切换到列表模式 + switchToListMode(mNoteEditor.getText().toString()); + } else { + if (!getWorkingText()) { + // 如果工作文本为空,并且未保存的文本中包含 "unchecked" 标识,则将其移除 + mWorkingNote.setWorkingText(mWorkingNote.getContent().replace(TAG_UNCHECKED + " ", "")); } + // 设置编辑框内容,并将用户查询结果高亮显示 + mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery)); + // 隐藏编辑框列表视图,显示笔记编辑视图 + mEditTextList.setVisibility(View.GONE); + mNoteEditor.setVisibility(View.VISIBLE); } +} private boolean getWorkingText() { /* @@ -925,17 +1095,21 @@ public class NoteEditActivity extends Activity implements OnClickListener, } private String makeShortcutIconTitle(String content) { + // 将原始内容中的特定字符串替换为空字符串,以删除特定标记 content = content.replace(TAG_CHECKED, ""); content = content.replace(TAG_UNCHECKED, ""); - return content.length() > SHORTCUT_ICON_TITLE_MAX_LEN ? content.substring(0, - SHORTCUT_ICON_TITLE_MAX_LEN) : content; + // 如果内容的长度超过了指定的最大长度,则返回内容的子字符串,否则返回原始内容 + return content.length() > SHORTCUT_ICON_TITLE_MAX_LEN ? content.substring(0, SHORTCUT_ICON_TITLE_MAX_LEN) : content; } - + private void showToast(int resId) { + // 显示一个短持续时间的Toast消息,消息内容为给定的资源ID的字符串 showToast(resId, Toast.LENGTH_SHORT); } - + private void showToast(int resId, int duration) { + // 显示一个具有自定义持续时间的Toast消息,消息内容为给定的资源ID的字符串 + // Toast消息在当前的上下文中显示 Toast.makeText(this, resId, duration).show(); } } diff --git a/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java b/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java index 2afe2a89..54244dcb 100644 --- a/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java +++ b/src/app/src/main/java/net/micode/notes/ui/NoteEditText.java @@ -101,117 +101,143 @@ public class NoteEditText extends EditText { @Override public boolean onTouchEvent(MotionEvent event) { + // 当用户触摸屏幕时执行以下操作 switch (event.getAction()) { case MotionEvent.ACTION_DOWN: - + // 获取触摸点的坐标 int x = (int) event.getX(); int y = (int) event.getY(); + // 调整坐标,考虑到文本框的内边距和滚动偏移 x -= getTotalPaddingLeft(); y -= getTotalPaddingTop(); x += getScrollX(); y += getScrollY(); - + // 获取布局信息,并确定触摸点所在的行和水平偏移位置 Layout layout = getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); + // 选中文本中特定偏移位置的字符 Selection.setSelection(getText(), off); break; } - + // 继续处理触摸事件 return super.onTouchEvent(event); } - + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { + // 按键按下时执行以下操作 switch (keyCode) { case KeyEvent.KEYCODE_ENTER: + // 如果存在文本变化监听器,则返回false,否则执行默认操作 if (mOnTextViewChangeListener != null) { return false; } break; case KeyEvent.KEYCODE_DEL: + // 记录删除操作前的光标位置 mSelectionStartBeforeDelete = getSelectionStart(); break; default: break; } + // 继续处理按键事件 return super.onKeyDown(keyCode, event); } - + @Override public boolean onKeyUp(int keyCode, KeyEvent event) { + // 按键释放时执行以下操作 switch(keyCode) { case KeyEvent.KEYCODE_DEL: if (mOnTextViewChangeListener != null) { + // 如果存在文本变化监听器,并且删除操作前光标位置为0,则调用相应的方法,并返回true if (0 == mSelectionStartBeforeDelete && mIndex != 0) { mOnTextViewChangeListener.onEditTextDelete(mIndex, getText().toString()); return true; } } else { - Log.d(TAG, "OnTextViewChangeListener was not seted"); + // 如果不存在文本变化监听器,则记录日志 + Log.d(TAG, "OnTextViewChangeListener was not set"); } break; case KeyEvent.KEYCODE_ENTER: if (mOnTextViewChangeListener != null) { + // 如果存在文本变化监听器,则获取光标位置和文本内容,并调用相应的方法 int selectionStart = getSelectionStart(); String text = getText().subSequence(selectionStart, length()).toString(); setText(getText().subSequence(0, selectionStart)); mOnTextViewChangeListener.onEditTextEnter(mIndex + 1, text); } else { - Log.d(TAG, "OnTextViewChangeListener was not seted"); + // 如果不存在文本变化监听器,则记录日志 + Log.d(TAG, "OnTextViewChangeListener was not set"); } break; default: break; } + // 继续处理按键事件 return super.onKeyUp(keyCode, event); } - @Override - protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { - if (mOnTextViewChangeListener != null) { - if (!focused && TextUtils.isEmpty(getText())) { - mOnTextViewChangeListener.onTextChange(mIndex, false); - } else { - mOnTextViewChangeListener.onTextChange(mIndex, true); - } + + + + + +@Override +protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { + if (mOnTextViewChangeListener != null) { + // 检查文本内容是否为空 + if (!focused && TextUtils.isEmpty(getText())) { + // 当焦点失去且文本为空时,调用回调函数通知文本发生变化 + mOnTextViewChangeListener.onTextChange(mIndex, false); + } else { + // 当焦点改变或文本不为空时,调用回调函数通知文本发生变化 + mOnTextViewChangeListener.onTextChange(mIndex, true); } - super.onFocusChanged(focused, direction, previouslyFocusedRect); } + // 调用父类的方法,处理焦点改变事件 + super.onFocusChanged(focused, direction, previouslyFocusedRect); +} - @Override - protected void onCreateContextMenu(ContextMenu menu) { - if (getText() instanceof Spanned) { - int selStart = getSelectionStart(); - int selEnd = getSelectionEnd(); - - int min = Math.min(selStart, selEnd); - int max = Math.max(selStart, selEnd); - - final URLSpan[] urls = ((Spanned) getText()).getSpans(min, max, URLSpan.class); - if (urls.length == 1) { - int defaultResId = 0; - for(String schema: sSchemaActionResMap.keySet()) { - if(urls[0].getURL().indexOf(schema) >= 0) { - defaultResId = sSchemaActionResMap.get(schema); - break; - } - } - - if (defaultResId == 0) { - defaultResId = R.string.note_link_other; +@Override +protected void onCreateContextMenu(ContextMenu menu) { + if (getText() instanceof Spanned) { + int selStart = getSelectionStart(); + int selEnd = getSelectionEnd(); + + int min = Math.min(selStart, selEnd); + int max = Math.max(selStart, selEnd); + + // 获取选中文本中的 URLSpan 对象 + final URLSpan[] urls = ((Spanned) getText()).getSpans(min, max, URLSpan.class); + if (urls.length == 1) { + int defaultResId = 0; + // 根据 URL 的 schema 查找对应的默认资源 ID + for(String schema: sSchemaActionResMap.keySet()) { + if(urls[0].getURL().indexOf(schema) >= 0) { + defaultResId = sSchemaActionResMap.get(schema); + break; } + } - menu.add(0, 0, 0, defaultResId).setOnMenuItemClickListener( - new OnMenuItemClickListener() { - public boolean onMenuItemClick(MenuItem item) { - // goto a new intent - urls[0].onClick(NoteEditText.this); - return true; - } - }); + if (defaultResId == 0) { + defaultResId = R.string.note_link_other; } + + // 向上下文菜单添加选项,并设置点击监听器 + menu.add(0, 0, 0, defaultResId).setOnMenuItemClickListener( + new OnMenuItemClickListener() { + public boolean onMenuItemClick(MenuItem item) { + // 执行跳转到新 Intent 的操作 + urls[0].onClick(NoteEditText.this); + return true; + } + }); } - super.onCreateContextMenu(menu); } + // 调用父类的方法,创建右键菜单 + super.onCreateContextMenu(menu); +} } diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java b/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java index 58bf94d1..6c00ca8e 100644 --- a/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java +++ b/src/app/src/main/java/net/micode/notes/ui/NotesListActivity.java @@ -149,30 +149,41 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { + // 检查返回结果是否为成功,并且请求码是打开或新建节点的请求码 if (resultCode == RESULT_OK && (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) { + // 清空列表适配器的游标 mNotesListAdapter.changeCursor(null); } else { + // 调用父类的方法,处理返回结果 super.onActivityResult(requestCode, resultCode, data); } } - + private void setAppInfoFromRawRes() { + // 获取默认的 SharedPreference 对象 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) { + // 创建一个 StringBuilder 对象来存储从文件中读取的内容 StringBuilder sb = new StringBuilder(); InputStream in = null; try { - in = getResources().openRawResource(R.raw.introduction); + // 打开 raw 文件夹下的 introduction 资源文件 + in = getResources().openRawResource(R.raw.introduction); if (in != null) { + // 创建 InputStreamReader 对象读取输入流 InputStreamReader isr = new InputStreamReader(in); + // 创建 BufferedReader 对象读取字符流 BufferedReader br = new BufferedReader(isr); - char [] buf = new char[1024]; + // 创建字符数组缓冲区 + char[] buf = new char[1024]; int len = 0; + // 读取字符流内容并追加到 StringBuilder 中 while ((len = br.read(buf)) > 0) { sb.append(buf, 0, len); } } else { + // 发生错误时打印错误信息 Log.e(TAG, "Read introduction file error"); return; } @@ -180,111 +191,127 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt e.printStackTrace(); return; } finally { - if(in != null) { + if (in != null) { try { in.close(); } catch (IOException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } } - + + // 创建一个空的 WorkingNote 对象 WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER, AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE, ResourceParser.RED); + // 设置 WorkingNote 对象的文本内容为从文件中读取的内容 note.setWorkingText(sb.toString()); + // 保存 WorkingNote,并将其设置为已加入介绍的标志位 if (note.saveNote()) { sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit(); } else { + // 发生错误时打印错误信息 Log.e(TAG, "Save introduction note error"); return; } } } - @Override - protected void onStart() { - super.onStart(); - startAsyncNotesListQuery(); - } - private void initResources() { - mContentResolver = this.getContentResolver(); - mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver()); - mCurrentFolderId = Notes.ID_ROOT_FOLDER; - mNotesListView = (ListView) findViewById(R.id.notes_list); - mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null), - null, false); - mNotesListView.setOnItemClickListener(new OnListItemClickListener()); - mNotesListView.setOnItemLongClickListener(this); - mNotesListAdapter = new NotesListAdapter(this); - mNotesListView.setAdapter(mNotesListAdapter); - mAddNewNote = (Button) findViewById(R.id.btn_new_note); - mAddNewNote.setOnClickListener(this); - mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener()); - mDispatch = false; - mDispatchY = 0; - mOriginY = 0; - mTitleBar = (TextView) findViewById(R.id.tv_title_bar); - mState = ListEditState.NOTE_LIST; - mModeCallBack = new ModeCallback(); - } - private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener { - private DropdownMenu mDropDownMenu; - private ActionMode mActionMode; - private MenuItem mMoveMenu; - - 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); - if (mFocusNoteDataItem.getParentId() == Notes.ID_CALL_RECORD_FOLDER - || DataUtils.getUserFolderCount(mContentResolver) == 0) { - mMoveMenu.setVisible(false); - } else { - mMoveMenu.setVisible(true); - mMoveMenu.setOnMenuItemClickListener(this); - } - mActionMode = mode; - mNotesListAdapter.setChoiceMode(true); - mNotesListView.setLongClickable(false); - mAddNewNote.setVisibility(View.GONE); +@Override +protected void onStart() { + super.onStart(); + startAsyncNotesListQuery(); // 在活动启动时开始异步笔记列表查询 +} - 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(){ - public boolean onMenuItemClick(MenuItem item) { - mNotesListAdapter.selectAll(!mNotesListAdapter.isAllSelected()); - updateMenu(); - return true; - } +/** + * 初始化资源 + */ +private void initResources() { + mContentResolver = this.getContentResolver(); // 获取内容解析器 + mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver()); // 初始化后台查询处理器 + mCurrentFolderId = Notes.ID_ROOT_FOLDER; // 设置当前文件夹 ID 为根文件夹 ID + mNotesListView = (ListView) findViewById(R.id.notes_list); // 获取笔记列表视图 + mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null), null, false); // 为笔记列表添加底部视图 + mNotesListView.setOnItemClickListener(new OnListItemClickListener()); // 设置笔记列表项点击监听器 + mNotesListView.setOnItemLongClickListener(this); // 设置笔记列表项长按监听器 + mNotesListAdapter = new NotesListAdapter(this); // 初始化笔记列表适配器 + mNotesListView.setAdapter(mNotesListAdapter); // 设置笔记列表适配器 + mAddNewNote = (Button) findViewById(R.id.btn_new_note); // 获取新建笔记按钮 + mAddNewNote.setOnClickListener(this); // 设置新建笔记按钮点击监听器 + mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener()); // 设置新建笔记按钮触摸监听器 + mDispatch = false; + mDispatchY = 0; + mOriginY = 0; + mTitleBar = (TextView) findViewById(R.id.tv_title_bar); // 获取标题栏文本视图 + mState = ListEditState.NOTE_LIST; // 设置列表编辑状态为笔记列表状态 + mModeCallBack = new ModeCallback(); // 初始化模式回调 +} - }); - return true; +/** + * 模式回调类,实现列表多选模式监听器和菜单项点击监听器 + */ +private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener { + private DropdownMenu mDropDownMenu; // 下拉菜单 + private ActionMode mActionMode; // 操作模式 + private MenuItem mMoveMenu; // 移动菜单项 + + 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); // 查找移动菜单项 + if (mFocusNoteDataItem.getParentId() == Notes.ID_CALL_RECORD_FOLDER + || DataUtils.getUserFolderCount(mContentResolver) == 0) { + mMoveMenu.setVisible(false); // 如果当前笔记所属文件夹为通话记录文件夹或用户文件夹数量为 0,则隐藏移动菜单项 + } else { + mMoveMenu.setVisible(true); // 否则显示移动菜单项,并设置点击监听器 + 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); // 创建自定义视图 + 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(){ + 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); - mDropDownMenu.setTitle(format); - MenuItem item = mDropDownMenu.findItem(R.id.action_select_all); - if (item != null) { - if (mNotesListAdapter.isAllSelected()) { - item.setChecked(true); - item.setTitle(R.string.menu_deselect_all); - } else { - item.setChecked(false); - item.setTitle(R.string.menu_select_all); - } + private void updateMenu() { + int selectedCount = mNotesListAdapter.getSelectedCount(); + // 获取选择的数量 + + // 更新下拉菜单的标题 + String format = getResources().getString(R.string.menu_select_title, selectedCount); + mDropDownMenu.setTitle(format); + + // 找到菜单项 action_select_all + MenuItem item = mDropDownMenu.findItem(R.id.action_select_all); + if (item != null) { + // 如果所有的项目都被选择 + if (mNotesListAdapter.isAllSelected()) { + // 设置菜单项为选中状态,并更新标题为 "取消全选" + item.setChecked(true); + item.setTitle(R.string.menu_deselect_all); + } else { + // 设置菜单项为非选中状态,并更新标题为 "全选" + item.setChecked(false); + item.setTitle(R.string.menu_select_all); } } + } public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // TODO Auto-generated method stub @@ -313,33 +340,40 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } public boolean onMenuItemClick(MenuItem item) { + // 如果没有选择任何项,则显示一个提示消息,并返回true表示处理了菜单项的点击事件 if (mNotesListAdapter.getSelectedCount() == 0) { Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none), Toast.LENGTH_SHORT).show(); return true; } - + int itemId = item.getItemId(); if (itemId == 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())); + // 设置对话框的“确定”按钮点击事件 builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { + public void onClick(DialogInterface dialog, int which) { + // 执行批量删除操作 batchDelete(); } }); + // 设置对话框的“取消”按钮点击事件 builder.setNegativeButton(android.R.string.cancel, null); builder.show(); } else if (itemId == R.id.move) { + // 启动查询目标文件夹的操作 startQueryDestinationFolders(); } else { + // 对于其他菜单项的点击事件,直接返回false表示未处理 return false; } + // 返回true表示已处理菜单项的点击事件 return true; } } @@ -356,20 +390,13 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt int eventY = start + (int) event.getY(); /** * Minus TitleBar's height + * 减去标题栏的高度,适应子文件夹状态 */ if (mState == ListEditState.SUB_FOLDER) { eventY -= mTitleBar.getHeight(); start -= mTitleBar.getHeight(); } - /** - * HACKME:When click the transparent part of "New Note" button, dispatch - * the event to the list view behind this button. The transparent part of - * "New Note" button could be expressed by formula y=-0.12x+94(Unit:pixel) - * and the line top of the button. The coordinate based on left of the "New - * Note" button. The 94 represents maximum height of the transparent part. - * 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. - */ + // 计算是否在可触摸区域内 if (event.getY() < (event.getX() * (-0.12) + 94)) { View view = mNotesListView.getChildAt(mNotesListView.getChildCount() - 1 - mNotesListView.getFooterViewsCount()); @@ -403,31 +430,35 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } 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"); } - + + // 后台异步查询处理器 private final class BackgroundQueryHandler extends AsyncQueryHandler { public BackgroundQueryHandler(ContentResolver contentResolver) { super(contentResolver); } - + @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { switch (token) { case FOLDER_NOTE_LIST_QUERY_TOKEN: + // 查询完成后更新数据适配器 mNotesListAdapter.changeCursor(cursor); break; case FOLDER_LIST_QUERY_TOKEN: if (cursor != null && cursor.getCount() > 0) { + // 查询到文件夹数据后显示文件夹列表菜单 showFolderListMenu(cursor); } else { Log.e(TAG, "Query folder failed"); @@ -438,14 +469,17 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt } } } - + + // 显示文件夹列表菜单 private void showFolderListMenu(Cursor cursor) { AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); builder.setTitle(R.string.menu_title_select_folder); + final FoldersListAdapter adapter = new FoldersListAdapter(this, cursor); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { - + public void onClick(DialogInterface dialog, int which) { + // 将选中的笔记移动到所选的文件夹 DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter.getSelectedItemIds(), adapter.getItemId(which)); Toast.makeText( @@ -457,52 +491,67 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt mModeCallBack.finishActionMode(); } }); + builder.show(); } - + + // 创建新的笔记 private void createNewNote() { Intent intent = new Intent(this, NoteEditActivity.class); intent.setAction(Intent.ACTION_INSERT_OR_EDIT); 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())) { - } else { - Log.e(TAG, "Delete notes error, should not happens"); - } +/** + * 批量删除笔记操作 + */ +private void batchDelete() { + new AsyncTask>() { + /** + * 在后台执行操作 + */ + protected HashSet doInBackground(Void... unused) { + // 获取选中的小部件 + HashSet widgets = mNotesListAdapter.getSelectedWidget(); + if (!isSyncMode()) { + // 如果未同步,则直接删除笔记 + if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter.getSelectedItemIds())) { + // 删除成功 } else { - // in sync mode, we'll move the deleted note into the trash - // folder - if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter - .getSelectedItemIds(), Notes.ID_TRASH_FOLER)) { - Log.e(TAG, "Move notes to trash folder error, should not happens"); - } + Log.e(TAG, "Delete notes error, should not happens"); + } + } else { + // 在同步模式下,将已删除的笔记移动到回收站文件夹 + if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter.getSelectedItemIds(), + Notes.ID_TRASH_FOLER)) { + Log.e(TAG, "Move notes to trash folder error, should not happens"); } - return widgets; } + return widgets; + } - @Override - protected void onPostExecute(HashSet widgets) { - if (widgets != null) { - for (AppWidgetAttribute widget : widgets) { - if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID - && widget.widgetType != Notes.TYPE_WIDGET_INVALIDE) { - updateWidget(widget.widgetId, widget.widgetType); - } + /** + * 在操作完成后更新小部件 + */ + @Override + protected void onPostExecute(HashSet widgets) { + if (widgets != null) { + // 更新与这些小部件相关联的小部件 + for (AppWidgetAttribute widget : widgets) { + if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID + && widget.widgetType != Notes.TYPE_WIDGET_INVALIDE) { + updateWidget(widget.widgetId, widget.widgetType); } } - mModeCallBack.finishActionMode(); } - }.execute(); - } + // 完成操作模式 + mModeCallBack.finishActionMode(); + } + }.execute(); +} private void deleteFolder(long folderId) { /* @@ -609,145 +658,151 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } - private void showCreateOrModifyFolderDialog(final boolean create) { - //好长啊太长了这个方法 - final AlertDialog.Builder builder = new AlertDialog.Builder(this); - View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); - final EditText etName = (EditText) view.findViewById(R.id.et_foler_name); - showSoftInput(); - if (!create) { - if (mFocusNoteDataItem != null) { - etName.setText(mFocusNoteDataItem.getSnippet()); - builder.setTitle(getString(R.string.menu_folder_change_name)); - } else { - Log.e(TAG, "The long click data item is null"); - return; - } + /** + * 显示创建或修改文件夹对话框 + * @param create true表示创建文件夹,false表示修改文件夹 + */ +private void showCreateOrModifyFolderDialog(final boolean create) { + final AlertDialog.Builder builder = new AlertDialog.Builder(this); + View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); + final EditText etName = (EditText) view.findViewById(R.id.et_foler_name); + showSoftInput(); // 显示软键盘 + if (!create) { + if (mFocusNoteDataItem != null) { + etName.setText(mFocusNoteDataItem.getSnippet()); // 设置文件夹名 + builder.setTitle(getString(R.string.menu_folder_change_name)); // 设置对话框标题为修改文件夹名 } else { - etName.setText(""); - builder.setTitle(this.getString(R.string.menu_create_folder)); + Log.e(TAG, "The long click data item is null"); // 如果长按的数据项为空,则记录错误日志并返回 + return; } + } else { + 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); + 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; // 结束操作 } - }); - - 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; - } - if (!create) { - if (!TextUtils.isEmpty(name)) { - ContentValues values = new ContentValues(); - values.put(NoteColumns.SNIPPET, name); - values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER); - values.put(NoteColumns.LOCAL_MODIFIED, 1); - mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID - + "=?", new String[] { - String.valueOf(mFocusNoteDataItem.getId()) - }); - } - } else if (!TextUtils.isEmpty(name)) { + if (!create) { + 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); + values.put(NoteColumns.SNIPPET, name); // 设置文件夹名 + values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER); // 设置类型为文件夹 + values.put(NoteColumns.LOCAL_MODIFIED, 1); // 设置本地修改标志为1 + mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID + + "=?", new String[] { + String.valueOf(mFocusNoteDataItem.getId()) // 根据文件夹id更新数据库中的文件夹名 + }); } - dialog.dismiss(); + } 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); // 插入数据库创建新的文件夹 } - }); - - if (TextUtils.isEmpty(etName.getText())) { - positive.setEnabled(false); + dialog.dismiss(); // 关闭对话框 } - /** - * When the name edit text is null, disable the positive button - */ - etName.addTextChangedListener(new TextWatcher() { - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - // TODO Auto-generated method stub + }); - } + if (TextUtils.isEmpty(etName.getText())) { + positive.setEnabled(false); // 如果文件夹名为空,禁用确认按钮 + } + etName.addTextChangedListener(new TextWatcher() { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } - public void onTextChanged(CharSequence s, int start, int before, int count) { - if (TextUtils.isEmpty(etName.getText())) { - positive.setEnabled(false); - } else { - positive.setEnabled(true); - } + public void onTextChanged(CharSequence s, int start, int before, int count) { + if (TextUtils.isEmpty(etName.getText())) { + positive.setEnabled(false); // 如果文件夹名为空,禁用确认按钮 + } else { + positive.setEnabled(true); // 如果文件夹名不为空,启用确认按钮 } + } - public void afterTextChanged(Editable s) { - // TODO Auto-generated method stub + public void afterTextChanged(Editable s) { + } + }); +} - } - }); +@Override +public void onBackPressed() { + // 处理返回键事件 + switch (mState) { + case SUB_FOLDER: + // 如果当前状态为子文件夹列表状态 + mCurrentFolderId = Notes.ID_ROOT_FOLDER; + mState = ListEditState.NOTE_LIST; + startAsyncNotesListQuery(); + mTitleBar.setVisibility(View.GONE); + break; + case CALL_RECORD_FOLDER: + // 如果当前状态为通话记录文件夹状态 + mCurrentFolderId = Notes.ID_ROOT_FOLDER; + mState = ListEditState.NOTE_LIST; + mAddNewNote.setVisibility(View.VISIBLE); + mTitleBar.setVisibility(View.GONE); + startAsyncNotesListQuery(); + break; + case NOTE_LIST: + // 如果当前状态为笔记列表状态,则调用父类的返回键处理方法 + super.onBackPressed(); + break; + default: + break; } +} - @Override - public void onBackPressed() { - switch (mState) { - case SUB_FOLDER: - mCurrentFolderId = Notes.ID_ROOT_FOLDER; - mState = ListEditState.NOTE_LIST; - startAsyncNotesListQuery(); - mTitleBar.setVisibility(View.GONE); - break; - case CALL_RECORD_FOLDER: - mCurrentFolderId = Notes.ID_ROOT_FOLDER; - mState = ListEditState.NOTE_LIST; - mAddNewNote.setVisibility(View.VISIBLE); - mTitleBar.setVisibility(View.GONE); - startAsyncNotesListQuery(); - break; - case NOTE_LIST: - super.onBackPressed(); - break; - default: - break; - } +/** + * 更新小部件 + * @param appWidgetId 小部件id + * @param appWidgetType 小部件类型 + */ +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); // 设置小部件Provider为2x类型 + } else if (appWidgetType == Notes.TYPE_WIDGET_4X) { + intent.setClass(this, NoteWidgetProvider_4x.class); // 设置小部件Provider为4x类型 + } else { + Log.e(TAG, "Unspported widget type"); // 记录错误日志并返回 + return; } - 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; - } - - intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { - appWidgetId - }); + intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] {appWidgetId}); // 设置小部件id - sendBroadcast(intent); - setResult(RESULT_OK, intent); - } + sendBroadcast(intent); // 发送广播通知小部件更新 + setResult(RESULT_OK, intent); +} - private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() { - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { - if (mFocusNoteDataItem != null) { - menu.setHeaderTitle(mFocusNoteDataItem.getSnippet()); - 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); - } +/** + * 文件夹长按菜单创建监听器 + */ +private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() { + public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { + if (mFocusNoteDataItem != null) { + menu.setHeaderTitle(mFocusNoteDataItem.getSnippet()); // 设置菜单标题为文件夹名 + 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) { @@ -768,6 +823,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt openFolder(mFocusNoteDataItem); break; case MENU_FOLDER_DELETE: + // 创建对话框确认删除文件夹 AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(getString(R.string.alert_title_delete)); builder.setIcon(android.R.drawable.ic_dialog_alert); @@ -782,21 +838,22 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt builder.show(); break; case MENU_FOLDER_CHANGE_NAME: + // 显示创建或修改文件夹的对话框 showCreateOrModifyFolderDialog(false); break; default: break; } - + return true; } - + @Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); if (mState == ListEditState.NOTE_LIST) { getMenuInflater().inflate(R.menu.note_list, menu); - // set sync or 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) { @@ -955,79 +1012,91 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt from.startActivityIfNeeded(intent, -1); } - private class OnListItemClickListener implements OnItemClickListener { +// 创建一个内部类 OnListItemClickListener,实现了 OnItemClickListener 接口,用于处理列表项的单击事件 +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) { - position = position - mNotesListView.getHeaderViewsCount(); - mModeCallBack.onItemCheckedStateChanged(null, position, id, - !mNotesListAdapter.isSelectedItem(position)); - } - return; + 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) { + position = position - mNotesListView.getHeaderViewsCount(); + mModeCallBack.onItemCheckedStateChanged(null, position, id, + !mNotesListAdapter.isSelectedItem(position)); } + return; + } - switch (mState) { - case NOTE_LIST: - if (item.getType() == Notes.TYPE_FOLDER - || item.getType() == Notes.TYPE_SYSTEM) { - openFolder(item); - } else if (item.getType() == Notes.TYPE_NOTE) { - openNode(item); - } else { - Log.e(TAG, "Wrong note type in NOTE_LIST"); - } - break; - case SUB_FOLDER: - case CALL_RECORD_FOLDER: - if (item.getType() == Notes.TYPE_NOTE) { - openNode(item); - } else { - Log.e(TAG, "Wrong note type in SUB_FOLDER"); - } - break; - default: - break; - } + // 根据当前的状态和被点击的列表项的类型执行相应的操作 + switch (mState) { + case NOTE_LIST: + // 在笔记列表状态下,如果被点击的列表项是文件夹或系统项,则打开文件夹;如果是笔记项,则打开笔记 + if (item.getType() == Notes.TYPE_FOLDER + || item.getType() == Notes.TYPE_SYSTEM) { + openFolder(item); + } else if (item.getType() == Notes.TYPE_NOTE) { + openNode(item); + } else { + Log.e(TAG, "Wrong note type in NOTE_LIST"); + } + break; + case SUB_FOLDER: + case CALL_RECORD_FOLDER: + // 在子文件夹列表状态或通话记录文件夹状态下,如果被点击的列表项是笔记项,则打开笔记 + if (item.getType() == Notes.TYPE_NOTE) { + openNode(item); + } else { + Log.e(TAG, "Wrong note type in SUB_FOLDER"); + } + break; + default: + break; } } - } - 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 + ")"; - - mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN, - null, - Notes.CONTENT_NOTE_URI, - FoldersListAdapter.PROJECTION, - selection, - new String[] { - String.valueOf(Notes.TYPE_FOLDER), - String.valueOf(Notes.ID_TRASH_FOLER), - String.valueOf(mCurrentFolderId) - }, - NoteColumns.MODIFIED_DATE + " DESC"); - } +} - public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { - if (view instanceof NotesListItem) { - mFocusNoteDataItem = ((NotesListItem) view).getItemData(); - if (mFocusNoteDataItem.getType() == Notes.TYPE_NOTE && !mNotesListAdapter.isInChoiceMode()) { - 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) { - mNotesListView.setOnCreateContextMenuListener(mFolderOnCreateContextMenuListener); +// 开始查询目标文件夹 +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 + ")"; + + // 使用 BackgroundQueryHandler 发起查询 + mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN, + null, + Notes.CONTENT_NOTE_URI, + FoldersListAdapter.PROJECTION, + selection, + new String[] { + String.valueOf(Notes.TYPE_FOLDER), + String.valueOf(Notes.ID_TRASH_FOLER), + String.valueOf(mCurrentFolderId) + }, + NoteColumns.MODIFIED_DATE + " DESC"); +} + +public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + if (view instanceof NotesListItem) { + // 获取长按的列表项的数据 + mFocusNoteDataItem = ((NotesListItem) view).getItemData(); + 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) { + // 如果长按的列表项是文件夹,则设置菜单创建监听器为文件夹菜单监听器 + mNotesListView.setOnCreateContextMenuListener(mFolderOnCreateContextMenuListener); } - return false; } + return false; +} } diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java b/src/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java index 51c9cb98..72a73d9a 100644 --- a/src/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java +++ b/src/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java @@ -91,33 +91,44 @@ public class NotesListAdapter extends CursorAdapter { public HashSet getSelectedItemIds() { HashSet itemSet = new HashSet(); + // 遍历选中项的位置集合 for (Integer position : mSelectedIndex.keySet()) { + // 如果选中状态为 true if (mSelectedIndex.get(position) == true) { + // 获取该位置对应的项的 ID Long id = getItemId(position); + // 如果 ID 为根文件夹的 ID,则输出错误日志 if (id == Notes.ID_ROOT_FOLDER) { Log.d(TAG, "Wrong item id, should not happen"); } else { + // 将 ID 添加到集合中 itemSet.add(id); } } } - + return itemSet; } - + public HashSet getSelectedWidget() { HashSet itemSet = new HashSet(); + // 遍历选中项的位置集合 for (Integer position : mSelectedIndex.keySet()) { + // 如果选中状态为 true if (mSelectedIndex.get(position) == true) { + // 获取该位置对应的项的 Cursor Cursor c = (Cursor) getItem(position); + // 如果 Cursor 不为空 if (c != null) { AppWidgetAttribute widget = new AppWidgetAttribute(); NoteItemData item = new NoteItemData(mContext, c); + // 从项的数据中获取 Widget 的 ID 和类型 widget.widgetId = item.getWidgetId(); widget.widgetType = item.getWidgetType(); + // 将 Widget 添加到集合中 itemSet.add(widget); /** - * Don't close cursor here, only the adapter could close it + * 不要在这里关闭 Cursor,只有适配器可以关闭它 */ } else { Log.e(TAG, "Invalid cursor"); @@ -127,14 +138,16 @@ public class NotesListAdapter extends CursorAdapter { } return itemSet; } - + public int getSelectedCount() { Collection values = mSelectedIndex.values(); + // 如果选中项集合为 null,则返回 0 if (null == values) { return 0; } Iterator iter = values.iterator(); int count = 0; + // 遍历选中项的值集合,统计选中项的数量并返回 while (iter.hasNext()) { if (true == iter.next()) { count++; @@ -169,13 +182,21 @@ public class NotesListAdapter extends CursorAdapter { private void calcNotesCount() { mNotesCount = 0; + + // 循环遍历每一个项目 for (int i = 0; i < getCount(); i++) { + // 获取当前项对应的Cursor对象 Cursor c = (Cursor) getItem(i); + + // 检查当前Cursor对象是否有效 if (c != null) { + // 检查当前笔记的类型是否为普通笔记 if (NoteItemData.getNoteType(c) == Notes.TYPE_NOTE) { + // 增加笔记计数 mNotesCount++; } } else { + // 打印错误日志并返回 Log.e(TAG, "Invalid cursor"); return; } diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java b/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java index 1221e808..369c9880 100644 --- a/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java +++ b/src/app/src/main/java/net/micode/notes/ui/NotesListItem.java @@ -47,27 +47,31 @@ public class NotesListItem extends LinearLayout { mCallName = (TextView) findViewById(R.id.tv_name); mCheckBox = (CheckBox) findViewById(android.R.id.checkbox); } - + + // 绑定数据到列表项 public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) { + // 根据选择模式和数据类型设定复选框的可见性和选中状态 if (choiceMode && data.getType() == Notes.TYPE_NOTE) { mCheckBox.setVisibility(View.VISIBLE); mCheckBox.setChecked(checked); } else { mCheckBox.setVisibility(View.GONE); } - - mItemData = data; + + mItemData = data; // 将数据保存在类成员变量中 + + // 根据不同的数据类型和属性设置视图的可见性,文本内容和图像资源 if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { mCallName.setVisibility(View.GONE); mAlert.setVisibility(View.VISIBLE); mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); mTitle.setText(context.getString(R.string.call_record_folder_name) - + context.getString(R.string.format_folder_files_count, data.getNotesCount())); + + context.getString(R.string.format_folder_files_count, data.getNotesCount())); mAlert.setImageResource(R.drawable.call_record); } else if (data.getParentId() == Notes.ID_CALL_RECORD_FOLDER) { mCallName.setVisibility(View.VISIBLE); mCallName.setText(data.getCallName()); - mTitle.setTextAppearance(context,R.style.TextAppearanceSecondaryItem); + mTitle.setTextAppearance(context, R.style.TextAppearanceSecondaryItem); mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet())); if (data.hasAlert()) { mAlert.setImageResource(R.drawable.clock); @@ -78,11 +82,10 @@ public class NotesListItem extends LinearLayout { } else { mCallName.setVisibility(View.GONE); mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem); - + if (data.getType() == Notes.TYPE_FOLDER) { mTitle.setText(data.getSnippet() - + context.getString(R.string.format_folder_files_count, - data.getNotesCount())); + + context.getString(R.string.format_folder_files_count, data.getNotesCount())); mAlert.setVisibility(View.GONE); } else { mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet())); @@ -94,11 +97,14 @@ public class NotesListItem extends LinearLayout { } } } + + // 设置时间文本为相对时间格式 mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate())); - - setBackground(data); + + setBackground(data); // 设置背景 } - + + // 根据数据类型和属性设置背景 private void setBackground(NoteItemData data) { int id = data.getBgColorId(); if (data.getType() == Notes.TYPE_NOTE) { diff --git a/src/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java b/src/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java index 07c5f7ec..ef66eadc 100644 --- a/src/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java +++ b/src/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java @@ -72,28 +72,28 @@ public class NotesPreferenceActivity extends PreferenceActivity { @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); - - /* using the app icon for navigation */ + + /* 设置显示返回箭头 */ getActionBar().setDisplayHomeAsUpEnabled(true); - + + /* 从 XML 文件加载偏好设置 */ addPreferencesFromResource(R.xml.preferences); mAccountCategory = (PreferenceCategory) findPreference(PREFERENCE_SYNC_ACCOUNT_KEY); mReceiver = new GTaskReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(GTaskSyncService.GTASK_SERVICE_BROADCAST_NAME); registerReceiver(mReceiver, filter); - + mOriAccounts = null; View header = LayoutInflater.from(this).inflate(R.layout.settings_header, null); getListView().addHeaderView(header, null, true); } - + @Override protected void onResume() { super.onResume(); - - // need to set sync account automatically if user has added a new - // account + + // 需要在用户添加新帐户后自动设置同步帐户 if (mHasAddedAccount) { Account[] accounts = getGoogleAccounts(); if (mOriAccounts != null && accounts.length > mOriAccounts.length) { @@ -112,10 +112,10 @@ public class NotesPreferenceActivity extends PreferenceActivity { } } } - + refreshUI(); } - + @Override protected void onDestroy() { if (mReceiver != null) { @@ -123,10 +123,11 @@ public class NotesPreferenceActivity extends PreferenceActivity { } super.onDestroy(); } - + + /* 加载帐户偏好设置 */ private void loadAccountPreference() { mAccountCategory.removeAll(); - + Preference accountPref = new Preference(this); final String defaultAccount = getSyncAccountName(this); accountPref.setTitle(getString(R.string.preferences_account_title)); @@ -135,11 +136,10 @@ public class NotesPreferenceActivity extends PreferenceActivity { public boolean onPreferenceClick(Preference preference) { if (!GTaskSyncService.isSyncing()) { if (TextUtils.isEmpty(defaultAccount)) { - // the first time to set account + // 第一次设置帐户 showSelectAccountAlertDialog(); } else { - // if the account has already been set, we need to promp - // user about the risk + // 如果帐户已经设置,需要提示用户风险 showChangeAccountConfirmAlertDialog(); } } else { @@ -150,186 +150,194 @@ public class NotesPreferenceActivity extends PreferenceActivity { return true; } }); - + mAccountCategory.addPreference(accountPref); } - private void loadSyncButton() { - Button syncButton = (Button) findViewById(R.id.preference_sync_button); - TextView lastSyncTimeView = (TextView) findViewById(R.id.prefenerece_sync_status_textview); - - // set button state - if (GTaskSyncService.isSyncing()) { - syncButton.setText(getString(R.string.preferences_button_sync_cancel)); - syncButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - GTaskSyncService.cancelSync(NotesPreferenceActivity.this); - } - }); - } else { - syncButton.setText(getString(R.string.preferences_button_sync_immediately)); - syncButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - GTaskSyncService.startSync(NotesPreferenceActivity.this); - } - }); - } - syncButton.setEnabled(!TextUtils.isEmpty(getSyncAccountName(this))); - - // set last sync time - if (GTaskSyncService.isSyncing()) { - lastSyncTimeView.setText(GTaskSyncService.getProgressString()); +// 加载同步按钮 +private void loadSyncButton() { + // 获取同步按钮和上次同步时间视图 + Button syncButton = (Button) findViewById(R.id.preference_sync_button); + TextView lastSyncTimeView = (TextView) findViewById(R.id.prefenerece_sync_status_textview); + + // 设置按钮状态 + if (GTaskSyncService.isSyncing()) { + // 如果正在同步,则显示取消同步按钮,并设置点击监听器取消同步 + syncButton.setText(getString(R.string.preferences_button_sync_cancel)); + syncButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + GTaskSyncService.cancelSync(NotesPreferenceActivity.this); + } + }); + } else { + // 如果未在同步,则显示立即同步按钮,并设置点击监听器开始同步 + syncButton.setText(getString(R.string.preferences_button_sync_immediately)); + syncButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + GTaskSyncService.startSync(NotesPreferenceActivity.this); + } + }); + } + // 根据是否存在同步帐户来设置按钮是否可用 + syncButton.setEnabled(!TextUtils.isEmpty(getSyncAccountName(this))); + + // 设置上次同步时间 + if (GTaskSyncService.isSyncing()) { + // 如果正在同步,则显示同步进度,并设置视图可见 + lastSyncTimeView.setText(GTaskSyncService.getProgressString()); + lastSyncTimeView.setVisibility(View.VISIBLE); + } else { + // 如果未在同步,则获取上次同步时间并显示在视图中 + long lastSyncTime = getLastSyncTime(this); + if (lastSyncTime != 0) { + lastSyncTimeView.setText(getString(R.string.preferences_last_sync_time, + DateFormat.format(getString(R.string.preferences_last_sync_time_format), + lastSyncTime))); lastSyncTimeView.setVisibility(View.VISIBLE); } else { - long lastSyncTime = getLastSyncTime(this); - if (lastSyncTime != 0) { - lastSyncTimeView.setText(getString(R.string.preferences_last_sync_time, - DateFormat.format(getString(R.string.preferences_last_sync_time_format), - lastSyncTime))); - lastSyncTimeView.setVisibility(View.VISIBLE); - } else { - lastSyncTimeView.setVisibility(View.GONE); - } + // 如果没有上次同步时间,则隐藏视图 + lastSyncTimeView.setVisibility(View.GONE); } } +} - private void refreshUI() { - loadAccountPreference(); - loadSyncButton(); - } - - private void showSelectAccountAlertDialog() { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); - - View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null); - TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title); - titleTextView.setText(getString(R.string.preferences_dialog_select_account_title)); - TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle); - subtitleTextView.setText(getString(R.string.preferences_dialog_select_account_tips)); - - dialogBuilder.setCustomTitle(titleView); - dialogBuilder.setPositiveButton(null, null); - - Account[] accounts = getGoogleAccounts(); - String defAccount = getSyncAccountName(this); - - mOriAccounts = accounts; - mHasAddedAccount = false; +// 刷新用户界面 +private void refreshUI() { + // 加载帐户偏好设置 + loadAccountPreference(); + // 加载同步按钮 + loadSyncButton(); +} - if (accounts.length > 0) { - CharSequence[] items = new CharSequence[accounts.length]; - final CharSequence[] itemMapping = items; - int checkedItem = -1; - int index = 0; - for (Account account : accounts) { - if (TextUtils.equals(account.name, defAccount)) { - checkedItem = index; - } - items[index++] = account.name; +private void showSelectAccountAlertDialog() { + // 创建一个AlertDialog.Builder对象 + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); + + // 填充自定义布局,用作对话框标题 + View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null); + + // 设置对话框标题和副标题文本 + TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title); + titleTextView.setText(getString(R.string.preferences_dialog_select_account_title)); + TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle); + subtitleTextView.setText(getString(R.string.preferences_dialog_select_account_tips)); + + // 设置自定义标题视图 + dialogBuilder.setCustomTitle(titleView); + + // 禁用对话框的确认按钮 + dialogBuilder.setPositiveButton(null, null); + + // 获取Google帐户数组和默认帐户 + Account[] accounts = getGoogleAccounts(); + String defAccount = getSyncAccountName(this); + + // 保存原始帐户数组并设置添加账户的标志 + mOriAccounts = accounts; + mHasAddedAccount = false; + + if (accounts.length > 0) { + // 创建一个字符序列数组来存储帐户名,并找到选中项的索引 + CharSequence[] items = new CharSequence[accounts.length]; + final CharSequence[] itemMapping = items; + int checkedItem = -1; + int index = 0; + for (Account account : accounts) { + if (TextUtils.equals(account.name, defAccount)) { + checkedItem = index; } - dialogBuilder.setSingleChoiceItems(items, checkedItem, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - setSyncAccount(itemMapping[which].toString()); - dialog.dismiss(); - refreshUI(); - } - }); + items[index++] = account.name; } - - View addAccountView = LayoutInflater.from(this).inflate(R.layout.add_account_text, null); - dialogBuilder.setView(addAccountView); - - final AlertDialog dialog = dialogBuilder.show(); - addAccountView.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - mHasAddedAccount = true; - Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS"); - intent.putExtra(AUTHORITIES_FILTER_KEY, new String[] { - "gmail-ls" + // 设置单选项列表,其中帐户名为选项文本,checkedItem为默认选中项 + dialogBuilder.setSingleChoiceItems(items, checkedItem, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + setSyncAccount(itemMapping[which].toString()); + dialog.dismiss(); + refreshUI(); + } }); - startActivityForResult(intent, -1); - dialog.dismiss(); - } - }); - } - - private void showChangeAccountConfirmAlertDialog() { - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); - - View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null); - TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title); - titleTextView.setText(getString(R.string.preferences_dialog_change_account_title, - getSyncAccountName(this))); - TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle); - subtitleTextView.setText(getString(R.string.preferences_dialog_change_account_warn_msg)); - dialogBuilder.setCustomTitle(titleView); - - CharSequence[] menuItemArray = new CharSequence[] { - getString(R.string.preferences_menu_change_account), - getString(R.string.preferences_menu_remove_account), - getString(R.string.preferences_menu_cancel) - }; - dialogBuilder.setItems(menuItemArray, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - if (which == 0) { - showSelectAccountAlertDialog(); - } else if (which == 1) { - removeSyncAccount(); - refreshUI(); - } - } - }); - dialogBuilder.show(); } - private Account[] getGoogleAccounts() { - AccountManager accountManager = AccountManager.get(this); - return accountManager.getAccountsByType("com.google"); - } + // 填充自定义布局,用作添加账户的视图 + View addAccountView = LayoutInflater.from(this).inflate(R.layout.add_account_text, null); + dialogBuilder.setView(addAccountView); + + // 显示对话框 + final AlertDialog dialog = dialogBuilder.show(); + // 单击添加账户视图时触发 + addAccountView.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + mHasAddedAccount = true; + // 打开系统添加账户设置界面 + Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS"); + intent.putExtra(AUTHORITIES_FILTER_KEY, new String[] { + "gmail-ls" + }); + startActivityForResult(intent, -1); + dialog.dismiss(); + } + }); +} - private void setSyncAccount(String account) { - if (!getSyncAccountName(this).equals(account)) { - SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); - SharedPreferences.Editor editor = settings.edit(); - if (account != null) { - editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, account); - } else { - editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, ""); +private void showChangeAccountConfirmAlertDialog() { + // 创建一个AlertDialog.Builder对象 + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this); + + // 填充自定义布局,用作对话框标题 + View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null); + TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title); + titleTextView.setText(getString(R.string.preferences_dialog_change_account_title, getSyncAccountName(this))); + TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle); + subtitleTextView.setText(getString(R.string.preferences_dialog_change_account_warn_msg)); + dialogBuilder.setCustomTitle(titleView); + + // 设置对话框的选项菜单 + CharSequence[] menuItemArray = new CharSequence[] { + getString(R.string.preferences_menu_change_account), + getString(R.string.preferences_menu_remove_account), + getString(R.string.preferences_menu_cancel) + }; + dialogBuilder.setItems(menuItemArray, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + if (which == 0) { + showSelectAccountAlertDialog(); + } else if (which == 1) { + removeSyncAccount(); + refreshUI(); } - editor.commit(); - - // clean up last sync time - setLastSyncTime(this, 0); - - // clean up local gtask related info - new Thread(new Runnable() { - public void run() { - ContentValues values = new ContentValues(); - values.put(NoteColumns.GTASK_ID, ""); - values.put(NoteColumns.SYNC_ID, 0); - getContentResolver().update(Notes.CONTENT_NOTE_URI, values, null, null); - } - }).start(); - - Toast.makeText(NotesPreferenceActivity.this, - getString(R.string.preferences_toast_success_set_accout, account), - Toast.LENGTH_SHORT).show(); } - } + }); + dialogBuilder.show(); +} - private void removeSyncAccount() { +private Account[] getGoogleAccounts() { + // 获取账户管理器实例 + AccountManager accountManager = AccountManager.get(this); + // 返回所有com.google类型的账户 + return accountManager.getAccountsByType("com.google"); +} + +private void setSyncAccount(String account) { + // 如果当前同步账户与设置的账户不同 + if (!getSyncAccountName(this).equals(account)) { + // 获取SharedPreferences实例 SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); + // 获取SharedPreferences编辑器 SharedPreferences.Editor editor = settings.edit(); - if (settings.contains(PREFERENCE_SYNC_ACCOUNT_NAME)) { - editor.remove(PREFERENCE_SYNC_ACCOUNT_NAME); - } - if (settings.contains(PREFERENCE_LAST_SYNC_TIME)) { - editor.remove(PREFERENCE_LAST_SYNC_TIME); + // 如果账户不为null,设置同步账户名称 + if (account != null) { + editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, account); + } else { + // 否则清空同步账户名称 + editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, ""); } editor.commit(); - // clean up local gtask related info + // 清空上次同步时间 + setLastSyncTime(this, 0); + + // 清空本地gtask相关信息 new Thread(new Runnable() { public void run() { ContentValues values = new ContentValues(); @@ -338,51 +346,92 @@ public class NotesPreferenceActivity extends PreferenceActivity { getContentResolver().update(Notes.CONTENT_NOTE_URI, values, null, null); } }).start(); - } - public static String getSyncAccountName(Context context) { - SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, - Context.MODE_PRIVATE); - return settings.getString(PREFERENCE_SYNC_ACCOUNT_NAME, ""); + // 显示Toast提示设置成功 + Toast.makeText(NotesPreferenceActivity.this, + getString(R.string.preferences_toast_success_set_accout, account), + Toast.LENGTH_SHORT).show(); } +} - public static void setLastSyncTime(Context context, long time) { - SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, - Context.MODE_PRIVATE); - SharedPreferences.Editor editor = settings.edit(); - editor.putLong(PREFERENCE_LAST_SYNC_TIME, time); - editor.commit(); +private void removeSyncAccount() { + // 获取SharedPreferences实例 + SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE); + // 获取SharedPreferences编辑器 + SharedPreferences.Editor editor = settings.edit(); + // 如果包含同步账户名称信息,移除 + if (settings.contains(PREFERENCE_SYNC_ACCOUNT_NAME)) { + editor.remove(PREFERENCE_SYNC_ACCOUNT_NAME); } - - public static long getLastSyncTime(Context context) { - SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, - Context.MODE_PRIVATE); - return settings.getLong(PREFERENCE_LAST_SYNC_TIME, 0); + // 如果包含上次同步时间信息,移除 + if (settings.contains(PREFERENCE_LAST_SYNC_TIME)) { + editor.remove(PREFERENCE_LAST_SYNC_TIME); } + editor.commit(); + + // 清空本地gtask相关信息 + new Thread(new Runnable() { + public void run() { + ContentValues values = new ContentValues(); + values.put(NoteColumns.GTASK_ID, ""); + values.put(NoteColumns.SYNC_ID, 0); + getContentResolver().update(Notes.CONTENT_NOTE_URI, values, null, null); + } + }).start(); +} - private class GTaskReceiver extends BroadcastReceiver { +public static String getSyncAccountName(Context context) { + // 获取SharedPreferences实例 + SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, + Context.MODE_PRIVATE); + // 返回同步账户名称 + return settings.getString(PREFERENCE_SYNC_ACCOUNT_NAME, ""); +} - @Override - public void onReceive(Context context, Intent intent) { - refreshUI(); - if (intent.getBooleanExtra(GTaskSyncService.GTASK_SERVICE_BROADCAST_IS_SYNCING, false)) { - TextView syncStatus = (TextView) findViewById(R.id.prefenerece_sync_status_textview); - syncStatus.setText(intent - .getStringExtra(GTaskSyncService.GTASK_SERVICE_BROADCAST_PROGRESS_MSG)); - } +public static void setLastSyncTime(Context context, long time) { + // 获取SharedPreferences实例 + SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, + Context.MODE_PRIVATE); + // 获取SharedPreferences编辑器 + SharedPreferences.Editor editor = settings.edit(); + // 设置上次同步时间 + editor.putLong(PREFERENCE_LAST_SYNC_TIME, time); + editor.commit(); +} +public static long getLastSyncTime(Context context) { + // 获取SharedPreferences实例 + SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, + Context.MODE_PRIVATE); + // 返回上次同步时间 + return settings.getLong(PREFERENCE_LAST_SYNC_TIME, 0); +} + +private class GTaskReceiver extends BroadcastReceiver { + + @Override + public void onReceive(Context context, Intent intent) { + // 刷新UI界面 + refreshUI(); + // 如果正在同步任务 + if (intent.getBooleanExtra(GTaskSyncService.GTASK_SERVICE_BROADCAST_IS_SYNCING, false)) { + TextView syncStatus = (TextView) findViewById(R.id.prefenerece_sync_status_textview); + // 设置同步状态文本信息 + syncStatus.setText(intent.getStringExtra(GTaskSyncService.GTASK_SERVICE_BROADCAST_PROGRESS_MSG)); } } +} - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - Intent intent = new Intent(this, NotesListActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - startActivity(intent); - return true; - default: - return false; - } +public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + Intent intent = new Intent(this, NotesListActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + // 返回到主页面 + startActivity(intent); + return true; + default: + return false; } } +}