v1.2 更新功能修改bug部分注释

develop
denovochen 3 weeks ago
parent 803885a807
commit 3924ef1432

@ -0,0 +1,2 @@
#Sat Nov 02 00:06:01 CST 2024
java.home=D\:\\Android\\Android Studio\\jbr

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -7,7 +7,7 @@
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="Android Studio default JDK" />
<option name="gradleJvm" value="Embedded JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Notes-master.iml" filepath="$PROJECT_DIR$/.idea/Notes-master.iml" />
</modules>
</component>
</project>

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="Notes-master1" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../..">
<excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
<excludeFolder url="file://$MODULE_DIR$/../../build" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app:androidTest" external.linked.project.path="$MODULE_DIR$/../../../app" external.root.project.path="$MODULE_DIR$/../../.." external.system.id="GRADLE" external.system.module.type="sourceSet" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/main/res;file://$MODULE_DIR$/../../../app/src/debug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/androidTest/res;file://$MODULE_DIR$/../../../app/src/androidTestDebug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/androidTest/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/androidTest/debug" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../../../app/build/generated/aidl_source_output_dir/debugAndroidTest/out" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debugAndroidTest/out" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/renderscript_source_output_dir/debugAndroidTest/out" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/res/resValues/androidTest/debug" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/res/rs/androidTest/debug" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/source/buildConfig/androidTest/debug" />
<content url="file://$MODULE_DIR$/../../../app/src/androidTest" />
<content url="file://$MODULE_DIR$/../../../app/src/androidTestDebug" />
<orderEntry type="jdk" jdkName="Android API 30 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Notes-master1.app.main" scope="TEST" />
</component>
<component name="TestModuleProperties" production-module="Notes-master1.app.main" />
</module>

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$/../../../app" external.root.project.path="$MODULE_DIR$/../../.." external.system.id="GRADLE" external.system.module.group="Notes-master1" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
<option name="LAST_SUCCESSFUL_SYNC_AGP_VERSION" value="7.2.2" />
<option name="LAST_KNOWN_AGP_VERSION" value="7.2.2" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/main/res;file://$MODULE_DIR$/../../../app/src/debug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/androidTest/res;file://$MODULE_DIR$/../../../app/src/androidTestDebug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/androidTest/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/androidTest/debug" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/../../../app/build/intermediates/javac/debug/classes" />
<output-test url="file://$MODULE_DIR$/../../../app/build/intermediates/javac/debugUnitTest/classes" />
<exclude-output />
<content url="file://$MODULE_DIR$/../../../app">
<excludeFolder url="file://$MODULE_DIR$/../../../app/.gradle" />
<excludeFolder url="file://$MODULE_DIR$/../../../app/build" />
</content>
<orderEntry type="jdk" jdkName="Android API 30 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app:main" external.linked.project.path="$MODULE_DIR$/../../../app" external.root.project.path="$MODULE_DIR$/../../.." external.system.id="GRADLE" external.system.module.type="sourceSet" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/main/res;file://$MODULE_DIR$/../../../app/src/debug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/androidTest/res;file://$MODULE_DIR$/../../../app/src/androidTestDebug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/androidTest/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/androidTest/debug" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../../../app/build/generated/aidl_source_output_dir/debug/out" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debug/out">
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debug/out" isTestSource="false" generated="true" />
</content>
<content url="file://$MODULE_DIR$/../../../app/build/generated/renderscript_source_output_dir/debug/out" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/res/resValues/debug">
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/res/resValues/debug" type="java-resource" />
</content>
<content url="file://$MODULE_DIR$/../../../app/build/generated/res/rs/debug" />
<content url="file://$MODULE_DIR$/../../../app/build/generated/source/buildConfig/debug">
<sourceFolder url="file://$MODULE_DIR$/../../../app/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
</content>
<content url="file://$MODULE_DIR$/../../../app/src/debug" />
<content url="file://$MODULE_DIR$/../../../app/src/main">
<sourceFolder url="file://$MODULE_DIR$/../../../app/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/../../../app/src/main/res" type="java-resource" />
</content>
<orderEntry type="jdk" jdkName="Android API 30 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app:unitTest" external.linked.project.path="$MODULE_DIR$/../../../app" external.root.project.path="$MODULE_DIR$/../../.." external.system.id="GRADLE" external.system.module.type="sourceSet" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/main/res;file://$MODULE_DIR$/../../../app/src/debug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/debug" />
<option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/../../../app/src/androidTest/res;file://$MODULE_DIR$/../../../app/src/androidTestDebug/res;file://$MODULE_DIR$/../../../app/build/generated/res/rs/androidTest/debug;file://$MODULE_DIR$/../../../app/build/generated/res/resValues/androidTest/debug" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$/../../../app/build/generated/ap_generated_sources/debugUnitTest/out" />
<content url="file://$MODULE_DIR$/../../../app/src/test" />
<content url="file://$MODULE_DIR$/../../../app/src/testDebug" />
<orderEntry type="jdk" jdkName="Android API 30 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="Notes-master1.app.main" scope="TEST" />
</component>
<component name="TestModuleProperties" production-module="Notes-master1.app.main" />
</module>

@ -56,11 +56,12 @@
<property name="RunOnceActivity.cidr.known.project.marker" value="true" />
<property name="android.sdk.path" value="$PROJECT_DIR$/../SDK" />
<property name="cidr.known.project.marker" value="true" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/../Notes-master" />
<property name="show.inlinked.gradle.project.popup" value="false" />
</component>
<component name="RunManager">
<configuration name="app" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false">
<module name="Notes-master1.app.main" />
<module name="Notes-master1.app" />
<option name="DEPLOY" value="true" />
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
<option name="DEPLOY_AS_INSTANT" value="false" />
@ -93,6 +94,19 @@
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
</method>
</configuration>
<configuration default="true" type="JetRunConfigurationType">
<module name="Notes-master" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="KotlinStandaloneScriptRunConfigurationType">
<module name="Notes-master" />
<option name="filePath" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">

@ -1,6 +1,6 @@
#Fri Nov 01 15:26:19 CST 2024
net.micode.notes.app-main-7\:/drawable-hdpi/font_super.png=D\:\\Android\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\drawable-hdpi_font_super.png.flat
#Sat Nov 02 10:38:12 CST 2024
net.micode.notes.app-main-7\:/drawable-hdpi/call_record.png=D\:\\Android\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\drawable-hdpi_call_record.png.flat
net.micode.notes.app-main-7\:/drawable-hdpi/font_super.png=D\:\\Android\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\drawable-hdpi_font_super.png.flat
net.micode.notes.app-main-7\:/drawable-hdpi/new_note_normal.png=D\:\\Android\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\drawable-hdpi_new_note_normal.png.flat
net.micode.notes.app-main-7\:/drawable-hdpi/edit_yellow.9.png=D\:\\Android\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\drawable-hdpi_edit_yellow.9.png.flat
net.micode.notes.app-main-7\:/drawable-hdpi/edit_title_green.9.png=D\:\\Android\\Notes-master1\\app\\build\\intermediates\\merged_res\\debug\\drawable-hdpi_edit_title_green.9.png.flat

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="menu_share_ways">
<item>短信</item>
<item>邮件</item>
</string-array>
<plurals name="search_results_title">
<item quantity="other"><ns1:g id="NUMBER">%1$s</ns1:g> 条符合“<ns1:g id="SEARCH">%2$s</ns1:g>”的搜索结果</item>
</plurals>
<string name="alert_message_delete_folder">确认删除文件夹及所包含的便签吗?</string>
<string name="alert_message_delete_note">确认要删除该条便签吗?</string>
<string name="alert_message_delete_notes">确认要删除所选的 %d 条便签吗?</string>
<string name="alert_title_delete">删除</string>
<string name="app_name">便签</string>
<string name="app_widget2x2">便签2x2</string>
<string name="app_widget4x4">便签4x4</string>
<string name="button_delete">删除</string>
<string name="call_record_folder_name">通话便签</string>
<string name="datetime_dialog_cancel">取消</string>
<string name="datetime_dialog_ok">设置</string>
<string name="delete_remind_time_message">成功删除提醒</string>
<string name="error_note_empty_for_clock">不能为空便签设置闹钟提醒</string>
<string name="error_note_empty_for_send_to_desktop">不能将空便签发送到桌面</string>
<string name="error_note_not_exist">要查看的便签不存在</string>
<string name="error_sdcard_export">导出文本时发生错误请检查SD卡</string>
<string name="error_sdcard_unmounted">SD卡被占用不能操作</string>
<string name="error_sync_cancelled">同步已取消</string>
<string name="error_sync_internal">同步失败,发生内部错误</string>
<string name="error_sync_network">同步失败,请检查网络和帐号设置</string>
<string name="failed_sdcard_export">导出失败</string>
<string name="folder_exist">文件夹 %1$s 已存在,请重新命名</string>
<string name="format_date_ymd">yyyyMMdd</string>
<string name="format_datetime_mdhm">MM月dd日 kk:mm</string>
<string name="format_exported_file_location">已将文本文件(%1$s)输出至SD卡(%2$s)目录</string>
<string name="format_move_notes_to_folder">已将所选 %1$d 条便签移到 %2$s 文件夹</string>
<string name="hint_foler_name">请输入名称</string>
<string name="info_note_enter_desktop">已添加到桌面</string>
<string name="menu_alert">提醒我</string>
<string name="menu_create_folder">新建文件夹</string>
<string name="menu_delete">删除</string>
<string name="menu_deselect_all">取消全选</string>
<string name="menu_export_text">导出文本</string>
<string name="menu_folder_change_name">修改文件夹名称</string>
<string name="menu_folder_delete">刪除文件夹</string>
<string name="menu_folder_view">查看文件夹</string>
<string name="menu_font_large"></string>
<string name="menu_font_normal">正常</string>
<string name="menu_font_size">文字大小</string>
<string name="menu_font_small"></string>
<string name="menu_font_super">超大</string>
<string name="menu_list_mode">进入清单模式</string>
<string name="menu_move">移动到文件夹</string>
<string name="menu_move_parent_folder">上一级文件夹</string>
<string name="menu_normal_mode">退出清单模式</string>
<string name="menu_remove_remind">删除提醒</string>
<string name="menu_search">搜索</string>
<string name="menu_select_all">全选</string>
<string name="menu_select_none">没有选中项,操作无效</string>
<string name="menu_select_title">选中了 %d 项</string>
<string name="menu_send_to_desktop">发送到桌面</string>
<string name="menu_setting">设置</string>
<string name="menu_share">分享</string>
<string name="menu_sync">同步</string>
<string name="menu_sync_cancel">取消同步</string>
<string name="menu_title_select_folder">选择文件夹</string>
<string name="note_alert_expired">已过期</string>
<string name="note_link_email">发送邮件</string>
<string name="note_link_other">打开地图</string>
<string name="note_link_tel">呼叫电话</string>
<string name="note_link_web">浏览网页</string>
<string name="notealert_enter">查看</string>
<string name="notealert_ok">知道了</string>
<string name="notelist_menu_new">新建便签</string>
<string name="notelist_string_info">...</string>
<string name="preferences_account_summary">与google task同步便签记录</string>
<string name="preferences_account_title">同步账号</string>
<string name="preferences_add_account">添加账号</string>
<string name="preferences_bg_random_appear_title">新建便签背景颜色随机</string>
<string name="preferences_button_sync_cancel">取消同步</string>
<string name="preferences_button_sync_immediately">立即同步</string>
<string name="preferences_dialog_change_account_title">当前帐号 %1$s</string>
<string name="preferences_dialog_change_account_warn_msg">如更换同步帐号,过去的帐号同步信息将被清空,再次切换的同时可能会造成数据重复</string>
<string name="preferences_dialog_select_account_tips">请选择google帐号便签将与该帐号的google task内容同步。</string>
<string name="preferences_dialog_select_account_title">同步便签</string>
<string name="preferences_last_sync_time">上次同步于 %1$s</string>
<string name="preferences_menu_cancel">取消</string>
<string name="preferences_menu_change_account">更换账号</string>
<string name="preferences_menu_remove_account">删除账号</string>
<string name="preferences_title">设置</string>
<string name="preferences_toast_cannot_change_account">正在同步中,不能修改同步帐号</string>
<string name="preferences_toast_success_set_accout">同步帐号已设置为%1$s</string>
<string name="search">便签</string>
<string name="search_hint">搜索便签</string>
<string name="search_label">正在搜索便签</string>
<string name="search_setting_description">便签中的文字</string>
<string name="set_remind_time_message">创建提醒</string>
<string name="success_sdcard_export">导出成功</string>
<string name="success_sync_account">与%1$s同步成功</string>
<string name="sync_progress_init_list">正在获取服务器便签列表...</string>
<string name="sync_progress_login">登录%1$s...</string>
<string name="sync_progress_syncing">正在同步本地便签...</string>
<string name="ticker_cancel">同步已取消</string>
<string name="ticker_fail">同步失败</string>
<string name="ticker_success">同步成功</string>
<string name="ticker_syncing">同步便签...</string>
<string name="widget_havenot_content">没有关联内容,点击新建便签。</string>
<string name="widget_under_visit_mode">访客模式下,便签内容不可见</string>
</resources>

@ -1,108 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:ns1="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="menu_share_ways">
<item>短信</item>
<item>郵件</item>
</string-array>
<plurals name="search_results_title">
<item quantity="other"><ns1:g id="NUMBER">%1$s</ns1:g> 條符合”<ns1:g id="SEARCH">%2$s</ns1:g>“的搜尋結果</item>
</plurals>
<string name="alert_message_delete_folder">確認刪除檔夾及所包含的便簽嗎?</string>
<string name="alert_message_delete_note">确认要删除該條便籤嗎?</string>
<string name="alert_message_delete_notes">确认要刪除所選的 %d 條便籤嗎?</string>
<string name="alert_title_delete">刪除</string>
<string name="app_name">便簽</string>
<string name="app_widget2x2">便簽2x2</string>
<string name="app_widget4x4">便簽4x4</string>
<string name="button_delete">刪除</string>
<string name="call_record_folder_name">通話便籤</string>
<string name="datetime_dialog_cancel">取消</string>
<string name="datetime_dialog_ok">設置</string>
<string name="delete_remind_time_message">成功刪除提醒</string>
<string name="error_note_empty_for_clock">不能爲空便籤設置鬧鐘提醒</string>
<string name="error_note_empty_for_send_to_desktop">不能將空便籤發送到桌面</string>
<string name="error_note_not_exist">要查看的便籤不存在</string>
<string name="error_sdcard_export">導出TXT時發生錯誤請檢查SD卡</string>
<string name="error_sdcard_unmounted">SD卡被佔用不能操作</string>
<string name="error_sync_cancelled">同步已取消</string>
<string name="error_sync_internal">同步失敗,發生內部錯誤</string>
<string name="error_sync_network">同步失敗,請檢查網絡和帳號設置</string>
<string name="failed_sdcard_export">導出失敗</string>
<string name="folder_exist">文件夾 %1$s 已存在,請重新命名</string>
<string name="format_date_ymd">yyyyMMdd</string>
<string name="format_datetime_mdhm">MM月dd日 kk:mm</string>
<string name="format_exported_file_location">已將文本文件(%1$s)導出至SD(%2$s)目錄</string>
<string name="format_move_notes_to_folder">已將所選 %1$d 便籤移到 %2$s 文件夾</string>
<string name="hint_foler_name">請輸入名稱</string>
<string name="info_note_enter_desktop">已添加到桌面</string>
<string name="menu_alert">提醒我</string>
<string name="menu_create_folder">新建文件夾</string>
<string name="menu_delete">刪除</string>
<string name="menu_deselect_all">取消全選</string>
<string name="menu_export_text">導出文本</string>
<string name="menu_folder_change_name">修改文件夾名稱</string>
<string name="menu_folder_delete">刪除文件夾</string>
<string name="menu_folder_view">查看文件夾</string>
<string name="menu_font_large"></string>
<string name="menu_font_normal">正常</string>
<string name="menu_font_size">文字大小</string>
<string name="menu_font_small"></string>
<string name="menu_font_super">超大</string>
<string name="menu_list_mode">進入清單模式</string>
<string name="menu_move">移動到文件夾</string>
<string name="menu_move_parent_folder">上一級文件夾</string>
<string name="menu_normal_mode">退出清單模式</string>
<string name="menu_remove_remind">刪除提醒</string>
<string name="menu_search">搜尋</string>
<string name="menu_select_all">全選</string>
<string name="menu_select_none">沒有選中項,操作無效</string>
<string name="menu_select_title">選中了 %d 項</string>
<string name="menu_send_to_desktop">發送到桌面</string>
<string name="menu_setting">設置</string>
<string name="menu_share">分享</string>
<string name="menu_sync">同步</string>
<string name="menu_sync_cancel">取消同步</string>
<string name="menu_title_select_folder">選擇文件夾</string>
<string name="note_alert_expired">已過期</string>
<string name="note_link_email">發送郵件</string>
<string name="note_link_other">打開地圖</string>
<string name="note_link_tel">呼叫電話</string>
<string name="note_link_web">浏覽網頁</string>
<string name="notealert_enter">查看</string>
<string name="notealert_ok">知道了</string>
<string name="notelist_menu_new">新建便簽</string>
<string name="notelist_string_info">...</string>
<string name="preferences_account_summary">与google task同步便簽記錄</string>
<string name="preferences_account_title">同步賬號</string>
<string name="preferences_add_account">添加賬號</string>
<string name="preferences_bg_random_appear_title">新建便籤背景顏色隨機</string>
<string name="preferences_button_sync_cancel">取消同步</string>
<string name="preferences_button_sync_immediately">立即同步</string>
<string name="preferences_dialog_change_account_title">當前帳號 %1$s</string>
<string name="preferences_dialog_change_account_warn_msg">如更換同步帳號,過去的帳號同步信息將被清空,再次切換的同時可能會造成數據重復</string>
<string name="preferences_dialog_select_account_tips">請選擇google帳號便簽將與該帳號的google task內容同步。</string>
<string name="preferences_dialog_select_account_title">同步便簽</string>
<string name="preferences_last_sync_time">上次同步于 %1$s</string>
<string name="preferences_menu_cancel">取消</string>
<string name="preferences_menu_change_account">更換賬號</string>
<string name="preferences_menu_remove_account">刪除賬號</string>
<string name="preferences_title">設置</string>
<string name="preferences_toast_cannot_change_account">正在同步中,不能修改同步帳號</string>
<string name="preferences_toast_success_set_accout">同步帳號已設置為%1$s</string>
<string name="search">便籤</string>
<string name="search_hint">搜索便籤</string>
<string name="search_label">正在搜索便籤</string>
<string name="search_setting_description">便籤中的文字</string>
<string name="set_remind_time_message">創建提醒</string>
<string name="success_sdcard_export">導出成功</string>
<string name="success_sync_account">與%1$s同步成功</string>
<string name="sync_progress_init_list">正在獲取服務器便籤列表...</string>
<string name="sync_progress_login">登陸%1$s...</string>
<string name="sync_progress_syncing">正在同步本地便籤...</string>
<string name="ticker_cancel">同步已取消</string>
<string name="ticker_fail">同步失敗</string>
<string name="ticker_success">同步成功</string>
<string name="ticker_syncing">同步便簽...</string>
<string name="widget_havenot_content">沒有關聯內容,點擊新建便簽。</string>
<string name="widget_under_visit_mode">訪客模式下,便籤內容不可見</string>
</resources>

@ -132,8 +132,8 @@
<item name="android:textColor">@color/secondary_text_dark</item>
</style>
<style name="NoteActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions"/>
<item name="android:visibility">gone</item>
<item name="android:visibility">visible</item>
</style>
<style name="NoteTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/NoteActionBarStyle</item>

@ -41,8 +41,8 @@
</style><style name="NoteTheme" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/NoteActionBarStyle</item>
</style><style name="NoteActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions"/>
<item name="android:visibility">gone</item>
<item name="android:visibility">visible</item>
</style></file><file path="D:\Android\Notes-master1\app\src\main\res\values-zh-rCN\arrays.xml" qualifiers="zh-rCN"><string-array name="menu_share_ways">
<item>短信</item>
<item>邮件</item>

@ -1,4 +1,4 @@
#Fri Nov 01 15:49:42 CST 2024
#Tue Nov 05 22:04:33 CST 2024
base.0=D\:\\Android\\Notes-master1\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex
renamed.0=classes.dex
path.0=classes.dex

@ -1,7 +1,7 @@
{
"logs": [
{
"outputFile": "net.micode.notes.app-merged_res-5:/values-zh-rCN_values-zh-rCN.arsc.flat",
"outputFile": "D:\\Android\\AS\\.gradle\\daemon\\7.3.3\\net.micode.notes.app-merged_res-5:\\values-zh-rCN_values-zh-rCN.arsc.flat",
"map": [
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values-zh-rCN\\strings.xml",
@ -43,8 +43,137 @@
}
]
},
{
"outputFile": "D:\\Android\\AS\\.gradle\\daemon\\7.3.3\\net.micode.notes.app-merged_res-5:\\values-zh-rTW_values-zh-rTW.arsc.flat",
"map": [
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values-zh-rTW\\arrays.xml",
"from": {
"startLines": "18",
"startColumns": "4",
"startOffsets": "712",
"endLines": "21",
"endColumns": "19",
"endOffsets": "817"
},
"to": {
"startLines": "2",
"startColumns": "4",
"startOffsets": "105",
"endLines": "5",
"endColumns": "19",
"endOffsets": "210"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values-zh-rTW\\strings.xml",
"from": {
"startLines": "122,72,71,70,69,19,20,21,112,113,121,120,26,76,77,75,74,73,89,88,87,79,61,29,30,80,37,114,68,64,39,45,50,40,60,59,58,54,53,51,52,55,56,46,67,57,65,44,49,48,47,63,43,62,41,42,66,28,34,36,33,35,32,31,25,24,96,95,98,110,103,102,104,105,107,106,97,101,99,100,94,108,109,119,117,116,118,27,78,86,91,90,92,85,84,83,82,22,23",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "6507,3575,3509,3436,3386,827,867,915,6057,6102,6453,6403,1199,3835,3903,3776,3710,3647,4565,4505,4442,4035,2957,1369,1422,4089,1768,6159,3327,3114,1878,2159,2405,1931,2897,2844,2793,2598,2550,2456,2504,2644,2691,2202,3268,2741,3157,2116,2358,2302,2247,3059,2072,3017,1981,2022,3209,1318,1623,1719,1576,1672,1529,1484,1148,1095,4940,4881,5081,5982,5392,5323,5456,5534,5717,5644,5015,5268,5138,5203,4832,5821,5904,6365,6258,6210,6303,1261,3980,4383,4678,4620,4745,4335,4290,4242,4191,963,1029",
"endLines": "124,72,71,70,69,19,20,21,112,113,121,120,26,76,77,75,74,73,89,88,87,79,61,29,30,80,37,114,68,64,39,45,50,40,60,59,58,54,53,51,52,55,56,46,67,57,65,44,49,48,47,63,43,62,41,42,66,28,34,36,33,35,32,31,25,24,96,95,98,110,103,102,104,105,107,106,97,101,99,100,94,108,109,119,117,116,118,27,78,86,91,90,92,85,84,83,82,22,23",
"endColumns": "14,71,65,72,49,39,47,47,44,56,53,49,61,67,76,58,65,62,54,59,62,53,59,52,61,83,79,49,58,42,52,42,50,49,59,52,50,45,47,47,45,46,49,44,58,51,51,42,46,55,54,54,43,41,40,49,58,50,48,48,46,46,46,44,50,52,74,58,56,73,63,68,77,109,103,72,65,54,64,64,48,82,77,37,44,47,61,56,54,58,66,57,61,47,44,47,50,65,65",
"endOffsets": "6679,3642,3570,3504,3431,862,910,958,6097,6154,6502,6448,1256,3898,3975,3830,3771,3705,4615,4560,4500,4084,3012,1417,1479,4168,1843,6204,3381,3152,1926,2197,2451,1976,2952,2892,2839,2639,2593,2499,2545,2686,2736,2242,3322,2788,3204,2154,2400,2353,2297,3109,2111,3054,2017,2067,3263,1364,1667,1763,1618,1714,1571,1524,1194,1143,5010,4935,5133,6051,5451,5387,5529,5639,5816,5712,5076,5318,5198,5263,4876,5899,5977,6398,6298,6253,6360,1313,4030,4437,4740,4673,4802,4378,4330,4285,4237,1024,1090"
},
"to": {
"startLines": "6,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "215,384,456,522,595,645,685,733,781,826,883,937,987,1049,1117,1194,1253,1319,1382,1437,1497,1560,1614,1674,1727,1789,1873,1953,2003,2062,2105,2158,2201,2252,2302,2362,2415,2466,2512,2560,2608,2654,2701,2751,2796,2855,2907,2959,3002,3049,3105,3160,3215,3259,3301,3342,3392,3451,3502,3551,3600,3647,3694,3741,3786,3837,3890,3965,4024,4081,4155,4219,4288,4366,4476,4580,4653,4719,4774,4839,4904,4953,5036,5114,5152,5197,5245,5307,5364,5419,5478,5545,5603,5665,5713,5758,5806,5857,5923",
"endLines": "8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106",
"endColumns": "14,71,65,72,49,39,47,47,44,56,53,49,61,67,76,58,65,62,54,59,62,53,59,52,61,83,79,49,58,42,52,42,50,49,59,52,50,45,47,47,45,46,49,44,58,51,51,42,46,55,54,54,43,41,40,49,58,50,48,48,46,46,46,44,50,52,74,58,56,73,63,68,77,109,103,72,65,54,64,64,48,82,77,37,44,47,61,56,54,58,66,57,61,47,44,47,50,65,65",
"endOffsets": "379,451,517,590,640,680,728,776,821,878,932,982,1044,1112,1189,1248,1314,1377,1432,1492,1555,1609,1669,1722,1784,1868,1948,1998,2057,2100,2153,2196,2247,2297,2357,2410,2461,2507,2555,2603,2649,2696,2746,2791,2850,2902,2954,2997,3044,3100,3155,3210,3254,3296,3337,3387,3446,3497,3546,3595,3642,3689,3736,3781,3832,3885,3960,4019,4076,4150,4214,4283,4361,4471,4575,4648,4714,4769,4834,4899,4948,5031,5109,5147,5192,5240,5302,5359,5414,5473,5540,5598,5660,5708,5753,5801,5852,5918,5984"
}
}
]
},
{
"outputFile": "net.micode.notes.app-merged_res-5:/values_values.arsc.flat",
"map": [
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\colors.xml",
"from": {
"startLines": "-1",
"startColumns": "-1",
"startOffsets": "-1"
},
"to": {
"startLines": "12",
"startColumns": "4",
"startOffsets": "420",
"endColumns": "56",
"endOffsets": "472"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\styles.xml",
"from": {
"startLines": "-1,-1,68,-1,-1,-1,-1,-1,-1,-1,-1",
"startColumns": "-1,-1,4,-1,-1,-1,-1,-1,-1,-1,-1",
"startOffsets": "-1,-1,2876,-1,-1,-1,-1,-1,-1,-1,-1",
"endLines": "-1,-1,71,-1,-1,-1,-1,-1,-1,-1,-1",
"endColumns": "-1,-1,12,-1,-1,-1,-1,-1,-1,-1,-1",
"endOffsets": "-1,-1,3093,-1,-1,-1,-1,-1,-1,-1,-1"
},
"to": {
"startLines": "125,129,133,137,140,144,148,152,156,160,164",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "8124,8328,8539,8712,8872,9055,9240,9425,9628,9834,10017",
"endLines": "128,132,136,139,143,147,151,155,159,163,167",
"endColumns": "12,12,12,12,12,12,12,12,12,12,12",
"endOffsets": "8323,8534,8707,8867,9050,9235,9420,9623,9829,10012,10213"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\arrays.xml",
"from": {
"startLines": "-1,-1",
"startColumns": "-1,-1",
"startOffsets": "-1,-1"
},
"to": {
"startLines": "2,8",
"startColumns": "4,4",
"startOffsets": "105,300",
"endLines": "7,11",
"endColumns": "19,19",
"endOffsets": "295,415"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\strings.xml",
"from": {
"startLines": "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1",
"startColumns": "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1",
"startOffsets": "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"
},
"to": {
"startLines": "18,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "739,1092,1188,1271,1367,1436,1479,1531,1583,1632,1695,1753,1804,1888,1982,2090,2161,2245,2328,2394,2477,2579,2640,2702,2753,2831,2884,2944,3049,3108,3210,3265,3336,3385,3443,3490,3549,3606,3677,3738,3795,3845,3897,3950,4000,4050,4110,4163,4229,4291,4354,4401,4456,4544,4602,4664,4714,4759,4802,4862,4929,4984,5039,5092,5139,5192,5248,5296,5351,5404,5488,5555,5619,5715,5789,5870,5959,6122,6266,6345,6420,6502,6561,6641,6721,6776,6898,7001,7042,7095,7152,7226,7291,7359,7445,7525,7594,7688,7747,7802,7864,7924,8034",
"endLines": "22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124",
"endColumns": "14,95,82,95,68,42,51,51,48,62,57,50,83,93,107,70,83,82,65,82,101,60,61,50,77,52,59,104,58,101,54,70,48,57,46,58,56,70,60,56,49,51,52,49,49,59,52,65,61,62,46,54,87,57,61,49,44,42,59,66,54,54,52,46,52,55,47,54,52,83,66,63,95,73,80,88,162,143,78,74,81,58,79,79,54,121,102,40,52,56,73,64,67,85,79,68,93,58,54,61,59,109,89",
"endOffsets": "1087,1183,1266,1362,1431,1474,1526,1578,1627,1690,1748,1799,1883,1977,2085,2156,2240,2323,2389,2472,2574,2635,2697,2748,2826,2879,2939,3044,3103,3205,3260,3331,3380,3438,3485,3544,3601,3672,3733,3790,3840,3892,3945,3995,4045,4105,4158,4224,4286,4349,4396,4451,4539,4597,4659,4709,4754,4797,4857,4924,4979,5034,5087,5134,5187,5243,5291,5346,5399,5483,5550,5614,5710,5784,5865,5954,6117,6261,6340,6415,6497,6556,6636,6716,6771,6893,6996,7037,7090,7147,7221,7286,7354,7440,7520,7589,7683,7742,7797,7859,7919,8029,8119"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\dimens.xml",
"from": {
"startLines": "-1,-1,-1,-1,-1",
"startColumns": "-1,-1,-1,-1,-1",
"startOffsets": "-1,-1,-1,-1,-1"
},
"to": {
"startLines": "13,14,15,16,17",
"startColumns": "4,4,4,4,4",
"startOffsets": "477,529,582,635,687",
"endColumns": "51,52,52,51,51",
"endOffsets": "524,577,630,682,734"
}
}
]
},
{
"outputFile": "D:\\Android\\AS\\.gradle\\daemon\\7.3.3\\net.micode.notes.app-merged_res-5:\\values_values.arsc.flat",
"map": [
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\colors.xml",
@ -138,49 +267,6 @@
}
}
]
},
{
"outputFile": "net.micode.notes.app-merged_res-5:/values-zh-rTW_values-zh-rTW.arsc.flat",
"map": [
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values-zh-rTW\\arrays.xml",
"from": {
"startLines": "18",
"startColumns": "4",
"startOffsets": "712",
"endLines": "21",
"endColumns": "19",
"endOffsets": "817"
},
"to": {
"startLines": "2",
"startColumns": "4",
"startOffsets": "105",
"endLines": "5",
"endColumns": "19",
"endOffsets": "210"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values-zh-rTW\\strings.xml",
"from": {
"startLines": "122,72,71,70,69,19,20,21,112,113,121,120,26,76,77,75,74,73,89,88,87,79,61,29,30,80,37,114,68,64,39,45,50,40,60,59,58,54,53,51,52,55,56,46,67,57,65,44,49,48,47,63,43,62,41,42,66,28,34,36,33,35,32,31,25,24,96,95,98,110,103,102,104,105,107,106,97,101,99,100,94,108,109,119,117,116,118,27,78,86,91,90,92,85,84,83,82,22,23",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "6507,3575,3509,3436,3386,827,867,915,6057,6102,6453,6403,1199,3835,3903,3776,3710,3647,4565,4505,4442,4035,2957,1369,1422,4089,1768,6159,3327,3114,1878,2159,2405,1931,2897,2844,2793,2598,2550,2456,2504,2644,2691,2202,3268,2741,3157,2116,2358,2302,2247,3059,2072,3017,1981,2022,3209,1318,1623,1719,1576,1672,1529,1484,1148,1095,4940,4881,5081,5982,5392,5323,5456,5534,5717,5644,5015,5268,5138,5203,4832,5821,5904,6365,6258,6210,6303,1261,3980,4383,4678,4620,4745,4335,4290,4242,4191,963,1029",
"endLines": "124,72,71,70,69,19,20,21,112,113,121,120,26,76,77,75,74,73,89,88,87,79,61,29,30,80,37,114,68,64,39,45,50,40,60,59,58,54,53,51,52,55,56,46,67,57,65,44,49,48,47,63,43,62,41,42,66,28,34,36,33,35,32,31,25,24,96,95,98,110,103,102,104,105,107,106,97,101,99,100,94,108,109,119,117,116,118,27,78,86,91,90,92,85,84,83,82,22,23",
"endColumns": "14,71,65,72,49,39,47,47,44,56,53,49,61,67,76,58,65,62,54,59,62,53,59,52,61,83,79,49,58,42,52,42,50,49,59,52,50,45,47,47,45,46,49,44,58,51,51,42,46,55,54,54,43,41,40,49,58,50,48,48,46,46,46,44,50,52,74,58,56,73,63,68,77,109,103,72,65,54,64,64,48,82,77,37,44,47,61,56,54,58,66,57,61,47,44,47,50,65,65",
"endOffsets": "6679,3642,3570,3504,3431,862,910,958,6097,6154,6502,6448,1256,3898,3975,3830,3771,3705,4615,4560,4500,4084,3012,1417,1479,4168,1843,6204,3381,3152,1926,2197,2451,1976,2952,2892,2839,2639,2593,2499,2545,2686,2736,2242,3322,2788,3204,2154,2400,2353,2297,3109,2111,3054,2017,2067,3263,1364,1667,1763,1618,1714,1571,1524,1194,1143,5010,4935,5133,6051,5451,5387,5529,5639,5816,5712,5076,5318,5198,5263,4876,5899,5977,6398,6298,6253,6360,1313,4030,4437,4740,4673,4802,4378,4330,4285,4237,1024,1090"
},
"to": {
"startLines": "6,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "215,384,456,522,595,645,685,733,781,826,883,937,987,1049,1117,1194,1253,1319,1382,1437,1497,1560,1614,1674,1727,1789,1873,1953,2003,2062,2105,2158,2201,2252,2302,2362,2415,2466,2512,2560,2608,2654,2701,2751,2796,2855,2907,2959,3002,3049,3105,3160,3215,3259,3301,3342,3392,3451,3502,3551,3600,3647,3694,3741,3786,3837,3890,3965,4024,4081,4155,4219,4288,4366,4476,4580,4653,4719,4774,4839,4904,4953,5036,5114,5152,5197,5245,5307,5364,5419,5478,5545,5603,5665,5713,5758,5806,5857,5923",
"endLines": "8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106",
"endColumns": "14,71,65,72,49,39,47,47,44,56,53,49,61,67,76,58,65,62,54,59,62,53,59,52,61,83,79,49,58,42,52,42,50,49,59,52,50,45,47,47,45,46,49,44,58,51,51,42,46,55,54,54,43,41,40,49,58,50,48,48,46,46,46,44,50,52,74,58,56,73,63,68,77,109,103,72,65,54,64,64,48,82,77,37,44,47,61,56,54,58,66,57,61,47,44,47,50,65,65",
"endOffsets": "379,451,517,590,640,680,728,776,821,878,932,982,1044,1112,1189,1248,1314,1377,1432,1492,1555,1609,1669,1722,1784,1868,1948,1998,2057,2100,2153,2196,2247,2297,2357,2410,2461,2507,2555,2603,2649,2696,2746,2791,2850,2902,2954,2997,3044,3100,3155,3210,3254,3296,3337,3387,3446,3497,3546,3595,3642,3689,3736,3781,3832,3885,3960,4019,4076,4150,4214,4283,4361,4471,4575,4648,4714,4769,4834,4899,4948,5031,5109,5147,5192,5240,5302,5359,5414,5473,5540,5598,5660,5708,5753,5801,5852,5918,5984"
}
}
]
}
]
}

@ -1,7 +1,7 @@
{
"logs": [
{
"outputFile": "net.micode.notes.app-mergeDebugResources-3:/values/values.xml",
"outputFile": "D:\\Android\\AS\\.gradle\\daemon\\7.3.3\\net.micode.notes.app-mergeDebugResources-3:\\values\\values.xml",
"map": [
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\colors.xml",
@ -95,6 +95,92 @@
}
}
]
},
{
"outputFile": "net.micode.notes.app-mergeDebugResources-3:/values/values.xml",
"map": [
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\colors.xml",
"from": {
"startLines": "-1",
"startColumns": "-1",
"startOffsets": "-1"
},
"to": {
"startLines": "12",
"startColumns": "4",
"startOffsets": "420",
"endColumns": "56",
"endOffsets": "472"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\styles.xml",
"from": {
"startLines": "-1,-1,68,-1,-1,-1,-1,-1,-1,-1,-1",
"startColumns": "-1,-1,4,-1,-1,-1,-1,-1,-1,-1,-1",
"startOffsets": "-1,-1,2876,-1,-1,-1,-1,-1,-1,-1,-1",
"endLines": "-1,-1,71,-1,-1,-1,-1,-1,-1,-1,-1",
"endColumns": "-1,-1,12,-1,-1,-1,-1,-1,-1,-1,-1",
"endOffsets": "-1,-1,3093,-1,-1,-1,-1,-1,-1,-1,-1"
},
"to": {
"startLines": "125,129,133,137,140,144,148,152,156,160,164",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "8124,8328,8539,8712,8872,9055,9240,9425,9628,9834,10017",
"endLines": "128,132,136,139,143,147,151,155,159,163,167",
"endColumns": "12,12,12,12,12,12,12,12,12,12,12",
"endOffsets": "8323,8534,8707,8867,9050,9235,9420,9623,9829,10012,10213"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\arrays.xml",
"from": {
"startLines": "-1,-1",
"startColumns": "-1,-1",
"startOffsets": "-1,-1"
},
"to": {
"startLines": "2,8",
"startColumns": "4,4",
"startOffsets": "105,300",
"endLines": "7,11",
"endColumns": "19,19",
"endOffsets": "295,415"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\strings.xml",
"from": {
"startLines": "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1",
"startColumns": "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1",
"startOffsets": "-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1"
},
"to": {
"startLines": "18,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124",
"startColumns": "4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4",
"startOffsets": "739,1092,1188,1271,1367,1436,1479,1531,1583,1632,1695,1753,1804,1888,1982,2090,2161,2245,2328,2394,2477,2579,2640,2702,2753,2831,2884,2944,3049,3108,3210,3265,3336,3385,3443,3490,3549,3606,3677,3738,3795,3845,3897,3950,4000,4050,4110,4163,4229,4291,4354,4401,4456,4544,4602,4664,4714,4759,4802,4862,4929,4984,5039,5092,5139,5192,5248,5296,5351,5404,5488,5555,5619,5715,5789,5870,5959,6122,6266,6345,6420,6502,6561,6641,6721,6776,6898,7001,7042,7095,7152,7226,7291,7359,7445,7525,7594,7688,7747,7802,7864,7924,8034",
"endLines": "22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124",
"endColumns": "14,95,82,95,68,42,51,51,48,62,57,50,83,93,107,70,83,82,65,82,101,60,61,50,77,52,59,104,58,101,54,70,48,57,46,58,56,70,60,56,49,51,52,49,49,59,52,65,61,62,46,54,87,57,61,49,44,42,59,66,54,54,52,46,52,55,47,54,52,83,66,63,95,73,80,88,162,143,78,74,81,58,79,79,54,121,102,40,52,56,73,64,67,85,79,68,93,58,54,61,59,109,89",
"endOffsets": "1087,1183,1266,1362,1431,1474,1526,1578,1627,1690,1748,1799,1883,1977,2085,2156,2240,2323,2389,2472,2574,2635,2697,2748,2826,2879,2939,3044,3103,3205,3260,3331,3380,3438,3485,3544,3601,3672,3733,3790,3840,3892,3945,3995,4045,4105,4158,4224,4286,4349,4396,4451,4539,4597,4659,4709,4754,4797,4857,4924,4979,5034,5087,5134,5187,5243,5291,5346,5399,5483,5550,5614,5710,5784,5865,5954,6117,6261,6340,6415,6497,6556,6636,6716,6771,6893,6996,7037,7090,7147,7221,7286,7354,7440,7520,7589,7683,7742,7797,7859,7919,8029,8119"
}
},
{
"source": "D:\\Android\\Notes-master1\\app\\src\\main\\res\\values\\dimens.xml",
"from": {
"startLines": "-1,-1,-1,-1,-1",
"startColumns": "-1,-1,-1,-1,-1",
"startOffsets": "-1,-1,-1,-1,-1"
},
"to": {
"startLines": "13,14,15,16,17",
"startColumns": "4,4,4,4,4",
"startOffsets": "477,529,582,635,687",
"endColumns": "51,52,52,51,51",
"endOffsets": "524,577,630,682,734"
}
}
]
}
]
}

@ -25,10 +25,21 @@ import android.util.Log;
import java.util.HashMap;
/**
* ,
*/
public class Contact {
// 用于缓存电话号码和联系人姓名的映射关系
private static HashMap<String, String> sContactCache;
// 日志标签
private static final String TAG = "Contact";
/**
* SQL
* PHONE_NUMBERS_EQUAL -
* MIMETYPE -
* RAW_CONTACT_ID - phone_lookupID
*/
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN "
@ -36,36 +47,51 @@ public class Contact {
+ " FROM phone_lookup"
+ " WHERE min_match = '+')";
/**
*
* @param context
* @param phoneNumber
* @return ,null
*/
public static String getContact(Context context, String phoneNumber) {
// 初始化缓存Map(如果未初始化)
if(sContactCache == null) {
sContactCache = new HashMap<String, String>();
}
// 检查缓存中是否已存在该号码对应的联系人
if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
}
// 构造查询条件,将电话号码转换为标准格式
String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
// 查询联系人数据库
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME },
new String [] { Phone.DISPLAY_NAME }, // 只查询联系人显示名称
selection,
new String[] { phoneNumber },
null);
if (cursor != null && cursor.moveToFirst()) {
try {
// 获取联系人姓名
String name = cursor.getString(0);
// 将结果存入缓存
sContactCache.put(phoneNumber, name);
return name;
} catch (IndexOutOfBoundsException e) {
// 处理游标越界异常
Log.e(TAG, " Cursor get string error " + e.toString());
return null;
} finally {
// 确保关闭游标
cursor.close();
}
} else {
// 未找到匹配的联系人
Log.d(TAG, "No contact matched with number:" + phoneNumber);
return null;
}

@ -17,24 +17,32 @@
package net.micode.notes.data;
import android.net.Uri;
/**
* ,
*/
public class Notes {
// 内容提供者的授权字符串
public static final String AUTHORITY = "micode_notes";
// 日志标签
public static final String TAG = "Notes";
public static final int TYPE_NOTE = 0;
public static final int TYPE_FOLDER = 1;
public static final int TYPE_SYSTEM = 2;
// 笔记类型常量
public static final int TYPE_NOTE = 0; // 普通笔记
public static final int TYPE_FOLDER = 1; // 文件夹
public static final int TYPE_SYSTEM = 2; // 系统文件夹
/**
* Following IDs are system folders' identifiers
* {@link Notes#ID_ROOT_FOLDER } is default folder
* {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder
* {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records
* ID:
* {@link Notes#ID_ROOT_FOLDER }
* {@link Notes#ID_TEMPARAY_FOLDER }
* {@link Notes#ID_CALL_RECORD_FOLDER}
*/
public static final int ID_ROOT_FOLDER = 0;
public static final int ID_TEMPARAY_FOLDER = -1;
public static final int ID_CALL_RECORD_FOLDER = -2;
public static final int ID_TRASH_FOLER = -3;
// Intent传递数据时使用的Extra键名
public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date";
public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id";
public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id";
@ -42,209 +50,214 @@ public class Notes {
public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id";
public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date";
public static final int TYPE_WIDGET_INVALIDE = -1;
public static final int TYPE_WIDGET_2X = 0;
public static final int TYPE_WIDGET_4X = 1;
// Widget类型常量
public static final int TYPE_WIDGET_INVALIDE = -1; // 无效widget
public static final int TYPE_WIDGET_2X = 0; // 2x大小widget
public static final int TYPE_WIDGET_4X = 1; // 4x大小widget
/**
*
*/
public static class DataConstants {
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE;
}
/**
* Uri to query all notes and folders
* Uri
*/
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
/**
* Uri to query data
* Uri
*/
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
/**
*
*/
public interface NoteColumns {
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
* ID
* <P> : INTEGER (long) </P>
*/
public static final String ID = "_id";
/**
* The parent's id for note or folder
* <P> Type: INTEGER (long) </P>
* ID
* <P> : INTEGER (long) </P>
*/
public static final String PARENT_ID = "parent_id";
/**
* Created data for note or folder
* <P> Type: INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String CREATED_DATE = "created_date";
/**
* Latest modified date
* <P> Type: INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String MODIFIED_DATE = "modified_date";
/**
* Alert date
* <P> Type: INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String ALERTED_DATE = "alert_date";
/**
* Folder's name or text content of note
* <P> Type: TEXT </P>
*
* <P> : TEXT </P>
*/
public static final String SNIPPET = "snippet";
/**
* Note's widget id
* <P> Type: INTEGER (long) </P>
* widget ID
* <P> : INTEGER (long) </P>
*/
public static final String WIDGET_ID = "widget_id";
/**
* Note's widget type
* <P> Type: INTEGER (long) </P>
* widget
* <P> : INTEGER (long) </P>
*/
public static final String WIDGET_TYPE = "widget_type";
/**
* Note's background color's id
* <P> Type: INTEGER (long) </P>
* ID
* <P> : INTEGER (long) </P>
*/
public static final String BG_COLOR_ID = "bg_color_id";
/**
* For text note, it doesn't has attachment, for multi-media
* note, it has at least one attachment
* <P> Type: INTEGER </P>
*
* <P> : INTEGER </P>
*/
public static final String HAS_ATTACHMENT = "has_attachment";
/**
* Folder's count of notes
* <P> Type: INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String NOTES_COUNT = "notes_count";
/**
* The file type: folder or note
* <P> Type: INTEGER </P>
* :
* <P> : INTEGER </P>
*/
public static final String TYPE = "type";
/**
* The last sync id
* <P> Type: INTEGER (long) </P>
* ID
* <P> : INTEGER (long) </P>
*/
public static final String SYNC_ID = "sync_id";
/**
* Sign to indicate local modified or not
* <P> Type: INTEGER </P>
*
* <P> : INTEGER </P>
*/
public static final String LOCAL_MODIFIED = "local_modified";
/**
* Original parent id before moving into temporary folder
* <P> Type : INTEGER </P>
* ID
* <P> : INTEGER </P>
*/
public static final String ORIGIN_PARENT_ID = "origin_parent_id";
/**
* The gtask id
* <P> Type : TEXT </P>
* GoogleID
* <P> : TEXT </P>
*/
public static final String GTASK_ID = "gtask_id";
/**
* The version code
* <P> Type : INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String VERSION = "version";
}
/**
*
*/
public interface DataColumns {
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
* ID
* <P> : INTEGER (long) </P>
*/
public static final String ID = "_id";
/**
* The MIME type of the item represented by this row.
* <P> Type: Text </P>
* MIME
* <P> : Text </P>
*/
public static final String MIME_TYPE = "mime_type";
/**
* The reference id to note that this data belongs to
* <P> Type: INTEGER (long) </P>
* ID
* <P> : INTEGER (long) </P>
*/
public static final String NOTE_ID = "note_id";
/**
* Created data for note or folder
* <P> Type: INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String CREATED_DATE = "created_date";
/**
* Latest modified date
* <P> Type: INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String MODIFIED_DATE = "modified_date";
/**
* Data's content
* <P> Type: TEXT </P>
*
* <P> : TEXT </P>
*/
public static final String CONTENT = "content";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* integer data type
* <P> Type: INTEGER </P>
* ,MIME
* <P> : INTEGER </P>
*/
public static final String DATA1 = "data1";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* integer data type
* <P> Type: INTEGER </P>
* ,MIME
* <P> : INTEGER </P>
*/
public static final String DATA2 = "data2";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* TEXT data type
* <P> Type: TEXT </P>
* ,MIME
* <P> : TEXT </P>
*/
public static final String DATA3 = "data3";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* TEXT data type
* <P> Type: TEXT </P>
* ,MIME
* <P> : TEXT </P>
*/
public static final String DATA4 = "data4";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* TEXT data type
* <P> Type: TEXT </P>
* ,MIME
* <P> : TEXT </P>
*/
public static final String DATA5 = "data5";
}
/**
*
*/
public static final class TextNote implements DataColumns {
/**
* Mode to indicate the text in check list mode or not
* <P> Type: Integer 1:check list mode 0: normal mode </P>
*
* <P> : Integer 1: 0: </P>
*/
public static final String MODE = DATA1;
@ -257,16 +270,19 @@ public class Notes {
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
}
/**
*
*/
public static final class CallNote implements DataColumns {
/**
* Call date for this record
* <P> Type: INTEGER (long) </P>
*
* <P> : INTEGER (long) </P>
*/
public static final String CALL_DATE = DATA1;
/**
* Phone number for this record
* <P> Type: TEXT </P>
*
* <P> : TEXT </P>
*/
public static final String PHONE_NUMBER = DATA3;

@ -26,22 +26,33 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
/**
* ,
*/
public class NotesDatabaseHelper extends SQLiteOpenHelper {
// 数据库名称
private static final String DB_NAME = "note.db";
// 数据库版本号
private static final int DB_VERSION = 4;
/**
*
*/
public interface TABLE {
public static final String NOTE = "note";
public static final String DATA = "data";
public static final String NOTE = "note"; // 笔记表
public static final String DATA = "data"; // 数据表
}
private static final String TAG = "NotesDatabaseHelper";
// 单例模式实例
private static NotesDatabaseHelper mInstance;
/**
* SQL
* :IDID
*/
private static final String CREATE_NOTE_TABLE_SQL =
"CREATE TABLE " + TABLE.NOTE + "(" +
NoteColumns.ID + " INTEGER PRIMARY KEY," +
@ -63,6 +74,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
")";
/**
* SQL
*
*/
private static final String CREATE_DATA_TABLE_SQL =
"CREATE TABLE " + TABLE.DATA + "(" +
DataColumns.ID + " INTEGER PRIMARY KEY," +
@ -78,12 +93,15 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
")";
/**
* NOTE_IDSQL
*/
private static final String CREATE_DATA_NOTE_ID_INDEX_SQL =
"CREATE INDEX IF NOT EXISTS note_id_index ON " +
TABLE.DATA + "(" + DataColumns.NOTE_ID + ");";
/**
* Increase folder's note count when move note to the folder
*
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
"CREATE TRIGGER increase_folder_count_on_update "+
@ -95,7 +113,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Decrease folder's note count when move note from folder
*
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
"CREATE TRIGGER decrease_folder_count_on_update " +
@ -108,7 +126,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Increase folder's note count when insert new note to the folder
*
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =
"CREATE TRIGGER increase_folder_count_on_insert " +
@ -120,7 +138,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Decrease folder's note count when delete note from the folder
*
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER =
"CREATE TRIGGER decrease_folder_count_on_delete " +
@ -133,7 +151,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Update note's content when insert data with type {@link DataConstants#NOTE}
* NOTE
*/
private static final String DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER =
"CREATE TRIGGER update_note_content_on_insert " +
@ -146,7 +164,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Update note's content when data with {@link DataConstants#NOTE} type has changed
* NOTE
*/
private static final String DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER =
"CREATE TRIGGER update_note_content_on_update " +
@ -159,7 +177,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Update note's content when data with {@link DataConstants#NOTE} type has deleted
* NOTE
*/
private static final String DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER =
"CREATE TRIGGER update_note_content_on_delete " +
@ -172,7 +190,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Delete datas belong to note which has been deleted
*
*/
private static final String NOTE_DELETE_DATA_ON_DELETE_TRIGGER =
"CREATE TRIGGER delete_data_on_delete " +
@ -183,7 +201,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Delete notes belong to folder which has been deleted
*
*/
private static final String FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER =
"CREATE TRIGGER folder_delete_notes_on_delete " +
@ -194,7 +212,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" END";
/**
* Move notes belong to folder which has been moved to trash folder
*
*/
private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER =
"CREATE TRIGGER folder_move_notes_on_trash " +
@ -206,10 +224,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
" END";
/**
*
* @param context
*/
public NotesDatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
/**
*
* @param db
*/
public void createNoteTable(SQLiteDatabase db) {
db.execSQL(CREATE_NOTE_TABLE_SQL);
reCreateNoteTableTriggers(db);
@ -217,6 +243,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "note table has been created");
}
/**
*
* @param db
*/
private void reCreateNoteTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
@ -235,18 +265,22 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER);
}
/**
*
* @param db
*/
private void createSystemFolder(SQLiteDatabase db) {
ContentValues values = new ContentValues();
/**
* call record foler for call notes
*
*/
values.put(NoteColumns.ID, Notes.ID_CALL_RECORD_FOLDER);
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
db.insert(TABLE.NOTE, null, values);
/**
* root folder which is default folder
* ()
*/
values.clear();
values.put(NoteColumns.ID, Notes.ID_ROOT_FOLDER);
@ -254,7 +288,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values);
/**
* temporary folder which is used for moving note
* ()
*/
values.clear();
values.put(NoteColumns.ID, Notes.ID_TEMPARAY_FOLDER);
@ -262,7 +296,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values);
/**
* create trash folder
*
*/
values.clear();
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
@ -270,6 +304,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values);
}
/**
*
* @param db
*/
public void createDataTable(SQLiteDatabase db) {
db.execSQL(CREATE_DATA_TABLE_SQL);
reCreateDataTableTriggers(db);
@ -277,6 +315,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "data table has been created");
}
/**
*
* @param db
*/
private void reCreateDataTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update");
@ -287,6 +329,11 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER);
}
/**
* NotesDatabaseHelper
* @param context
* @return NotesDatabaseHelper
*/
static synchronized NotesDatabaseHelper getInstance(Context context) {
if (mInstance == null) {
mInstance = new NotesDatabaseHelper(context);
@ -294,12 +341,22 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
return mInstance;
}
/**
*
* @param db
*/
@Override
public void onCreate(SQLiteDatabase db) {
createNoteTable(db);
createDataTable(db);
}
/**
*
* @param db
* @param oldVersion
* @param newVersion
*/
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
boolean reCreateTriggers = false;
@ -307,7 +364,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
if (oldVersion == 1) {
upgradeToV2(db);
skipV2 = true; // this upgrade including the upgrade from v2 to v3
skipV2 = true; // 此升级包含从v2到v3的升级
oldVersion++;
}
@ -333,6 +390,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
}
}
/**
* 2
* @param db
*/
private void upgradeToV2(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE);
db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA);
@ -340,21 +401,29 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
createDataTable(db);
}
/**
* 3
* @param db
*/
private void upgradeToV3(SQLiteDatabase db) {
// drop unused triggers
// 删除未使用的触发器
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert");
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_delete");
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_update");
// add a column for gtask id
// 添加gtask_id列
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_ID
+ " TEXT NOT NULL DEFAULT ''");
// add a trash system folder
// 添加回收站系统文件夹
ContentValues values = new ContentValues();
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
db.insert(TABLE.NOTE, null, values);
}
/**
* 4
* @param db
*/
private void upgradeToV4(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");

@ -34,24 +34,32 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE;
/**
* ,访
*/
public class NotesProvider extends ContentProvider {
// URI匹配器
private static final UriMatcher mMatcher;
// 数据库帮助类实例
private NotesDatabaseHelper mHelper;
// 日志标签
private static final String TAG = "NotesProvider";
private static final int URI_NOTE = 1;
private static final int URI_NOTE_ITEM = 2;
private static final int URI_DATA = 3;
private static final int URI_DATA_ITEM = 4;
private static final int URI_SEARCH = 5;
private static final int URI_SEARCH_SUGGEST = 6;
// URI匹配类型常量
private static final int URI_NOTE = 1; // 笔记URI
private static final int URI_NOTE_ITEM = 2; // 单条笔记URI
private static final int URI_DATA = 3; // 数据URI
private static final int URI_DATA_ITEM = 4; // 单条数据URI
private static final int URI_SEARCH = 5; // 搜索URI
private static final int URI_SEARCH_SUGGEST = 6; // 搜索建议URI
// 静态初始化URI匹配规则
static {
// 创建URI匹配器实例
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
// 添加各种URI匹配规则
mMatcher.addURI(Notes.AUTHORITY, "note", URI_NOTE);
mMatcher.addURI(Notes.AUTHORITY, "note/#", URI_NOTE_ITEM);
mMatcher.addURI(Notes.AUTHORITY, "data", URI_DATA);
@ -62,8 +70,9 @@ public class NotesProvider extends ContentProvider {
}
/**
* x'0A' represents the '\n' character in sqlite. For title and content in the search result,
* we will trim '\n' and white space in order to show more information.
*
* x'0A'sqlite'\n'
* ,
*/
private static final String NOTES_SEARCH_PROJECTION = NoteColumns.ID + ","
+ NoteColumns.ID + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA + ","
@ -73,50 +82,69 @@ public class NotesProvider extends ContentProvider {
+ "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + ","
+ "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA;
/**
* SQL
*/
private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION
+ " FROM " + TABLE.NOTE
+ " WHERE " + NoteColumns.SNIPPET + " LIKE ?"
+ " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER
+ " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE;
/**
*
*/
@Override
public boolean onCreate() {
// 初始化数据库帮助类
mHelper = NotesDatabaseHelper.getInstance(getContext());
return true;
}
/**
*
*/
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
// 初始化游标
Cursor c = null;
// 获取可读数据库实例
SQLiteDatabase db = mHelper.getReadableDatabase();
String id = null;
// 根据URI类型执行不同的查询操作
switch (mMatcher.match(uri)) {
case URI_NOTE:
// 查询所有笔记
c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null,
sortOrder);
break;
case URI_NOTE_ITEM:
// 查询单条笔记
id = uri.getPathSegments().get(1);
c = db.query(TABLE.NOTE, projection, NoteColumns.ID + "=" + id
+ parseSelection(selection), selectionArgs, null, null, sortOrder);
break;
case URI_DATA:
// 查询所有数据
c = db.query(TABLE.DATA, projection, selection, selectionArgs, null, null,
sortOrder);
break;
case URI_DATA_ITEM:
// 查询单条数据
id = uri.getPathSegments().get(1);
c = db.query(TABLE.DATA, projection, DataColumns.ID + "=" + id
+ parseSelection(selection), selectionArgs, null, null, sortOrder);
break;
case URI_SEARCH:
case URI_SEARCH_SUGGEST:
// 检查查询参数
if (sortOrder != null || projection != null) {
throw new IllegalArgumentException(
"do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");
}
// 获取搜索字符串
String searchString = null;
if (mMatcher.match(uri) == URI_SEARCH_SUGGEST) {
if (uri.getPathSegments().size() > 1) {
@ -126,11 +154,13 @@ public class NotesProvider extends ContentProvider {
searchString = uri.getQueryParameter("pattern");
}
// 如果搜索字符串为空则返回null
if (TextUtils.isEmpty(searchString)) {
return null;
}
try {
// 格式化搜索字符串并执行查询
searchString = String.format("%%%s%%", searchString);
c = db.rawQuery(NOTES_SNIPPET_SEARCH_QUERY,
new String[] { searchString });
@ -141,38 +171,56 @@ public class NotesProvider extends ContentProvider {
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
// 设置通知URI
if (c != null) {
c.setNotificationUri(getContext().getContentResolver(), uri);
}
return c;
}
/**
*
*/
/**
*
* @param uri URI
* @param values
* @return URI
*/
@Override
public Uri insert(Uri uri, ContentValues values) {
// 获取可写数据库实例
SQLiteDatabase db = mHelper.getWritableDatabase();
// 初始化数据ID、笔记ID和插入ID
long dataId = 0, noteId = 0, insertedId = 0;
switch (mMatcher.match(uri)) {
case URI_NOTE:
// 插入笔记数据
insertedId = noteId = db.insert(TABLE.NOTE, null, values);
break;
case URI_DATA:
// 插入笔记内容数据
if (values.containsKey(DataColumns.NOTE_ID)) {
// 从values中获取笔记ID
noteId = values.getAsLong(DataColumns.NOTE_ID);
} else {
// 记录错误日志:缺少笔记ID
Log.d(TAG, "Wrong data format without note id:" + values.toString());
}
// 插入数据并获取插入ID
insertedId = dataId = db.insert(TABLE.DATA, null, values);
break;
default:
// 未知URI异常
throw new IllegalArgumentException("Unknown URI " + uri);
}
// Notify the note uri
// 通知笔记URI发生变化
if (noteId > 0) {
getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null);
}
// Notify the data uri
// 通知数据URI发生变化
if (dataId > 0) {
getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null);
@ -181,22 +229,29 @@ public class NotesProvider extends ContentProvider {
return ContentUris.withAppendedId(uri, insertedId);
}
/**
*
*/
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
// 初始化删除计数
int count = 0;
String id = null;
// 获取可写数据库实例
SQLiteDatabase db = mHelper.getWritableDatabase();
boolean deleteData = false;
// 根据URI类型执行不同的删除操作
switch (mMatcher.match(uri)) {
case URI_NOTE:
// 删除笔记,确保只删除ID大于0的笔记
selection = "(" + selection + ") AND " + NoteColumns.ID + ">0 ";
count = db.delete(TABLE.NOTE, selection, selectionArgs);
break;
case URI_NOTE_ITEM:
// 删除单条笔记
id = uri.getPathSegments().get(1);
/**
* ID that smaller than 0 is system folder which is not allowed to
* trash
* ID0,
*/
long noteId = Long.valueOf(id);
if (noteId <= 0) {
@ -206,10 +261,12 @@ public class NotesProvider extends ContentProvider {
NoteColumns.ID + "=" + id + parseSelection(selection), selectionArgs);
break;
case URI_DATA:
// 删除所有数据
count = db.delete(TABLE.DATA, selection, selectionArgs);
deleteData = true;
break;
case URI_DATA_ITEM:
// 删除单条数据
id = uri.getPathSegments().get(1);
count = db.delete(TABLE.DATA,
DataColumns.ID + "=" + id + parseSelection(selection), selectionArgs);
@ -218,6 +275,7 @@ public class NotesProvider extends ContentProvider {
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
// 如果有数据被删除,发送通知
if (count > 0) {
if (deleteData) {
getContext().getContentResolver().notifyChange(Notes.CONTENT_NOTE_URI, null);
@ -227,28 +285,38 @@ public class NotesProvider extends ContentProvider {
return count;
}
/**
*
*/
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
// 初始化更新计数
int count = 0;
String id = null;
// 获取可写数据库实例
SQLiteDatabase db = mHelper.getWritableDatabase();
boolean updateData = false;
// 根据URI类型执行不同的更新操作
switch (mMatcher.match(uri)) {
case URI_NOTE:
// 更新笔记
increaseNoteVersion(-1, selection, selectionArgs);
count = db.update(TABLE.NOTE, values, selection, selectionArgs);
break;
case URI_NOTE_ITEM:
// 更新单条笔记
id = uri.getPathSegments().get(1);
increaseNoteVersion(Long.valueOf(id), selection, selectionArgs);
count = db.update(TABLE.NOTE, values, NoteColumns.ID + "=" + id
+ parseSelection(selection), selectionArgs);
break;
case URI_DATA:
// 更新所有数据
count = db.update(TABLE.DATA, values, selection, selectionArgs);
updateData = true;
break;
case URI_DATA_ITEM:
// 更新单条数据
id = uri.getPathSegments().get(1);
count = db.update(TABLE.DATA, values, DataColumns.ID + "=" + id
+ parseSelection(selection), selectionArgs);
@ -258,6 +326,7 @@ public class NotesProvider extends ContentProvider {
throw new IllegalArgumentException("Unknown URI " + uri);
}
// 如果有数据被更新,发送通知
if (count > 0) {
if (updateData) {
getContext().getContentResolver().notifyChange(Notes.CONTENT_NOTE_URI, null);
@ -267,11 +336,18 @@ public class NotesProvider extends ContentProvider {
return count;
}
/**
*
*/
private String parseSelection(String selection) {
return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : "");
}
/**
*
*/
private void increaseNoteVersion(long id, String selection, String[] selectionArgs) {
// 构建SQL更新语句
StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE ");
sql.append(TABLE.NOTE);
@ -279,6 +355,7 @@ public class NotesProvider extends ContentProvider {
sql.append(NoteColumns.VERSION);
sql.append("=" + NoteColumns.VERSION + "+1 ");
// 添加WHERE子句
if (id > 0 || !TextUtils.isEmpty(selection)) {
sql.append(" WHERE ");
}
@ -293,9 +370,13 @@ public class NotesProvider extends ContentProvider {
sql.append(selectString);
}
// 执行SQL语句
mHelper.getWritableDatabase().execSQL(sql.toString());
}
/**
* MIME
*/
@Override
public String getType(Uri uri) {
// TODO Auto-generated method stub

@ -24,12 +24,22 @@ import net.micode.notes.tool.GTaskStringUtils;
import org.json.JSONException;
import org.json.JSONObject;
/**
* ,Task
* Google Task
*/
public class MetaData extends Task {
// 日志标签
private final static String TAG = MetaData.class.getSimpleName();
// 关联的Google Task ID
private String mRelatedGid = null;
/**
*
* @param gid Google Task ID
* @param metaInfo JSON
*/
public void setMeta(String gid, JSONObject metaInfo) {
try {
metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid);
@ -40,15 +50,27 @@ public class MetaData extends Task {
setName(GTaskStringUtils.META_NOTE_NAME);
}
/**
* Google Task ID
* @return Google Task ID
*/
public String getRelatedGid() {
return mRelatedGid;
}
/**
*
* @return notestrue
*/
@Override
public boolean isWorthSaving() {
return getNotes() != null;
}
/**
* JSON
* @param js JSON
*/
@Override
public void setContentByRemoteJSON(JSONObject js) {
super.setContentByRemoteJSON(js);
@ -63,17 +85,31 @@ public class MetaData extends Task {
}
}
/**
* JSON()
* @param js JSON
* @throws IllegalAccessError
*/
@Override
public void setContentByLocalJSON(JSONObject js) {
// this function should not be called
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");
}
/**
* JSON()
* @throws IllegalAccessError
*/
@Override
public JSONObject getLocalJSONFromContent() {
throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called");
}
/**
* ()
* @param c
* @throws IllegalAccessError
*/
@Override
public int getSyncAction(Cursor c) {
throw new IllegalAccessError("MetaData:getSyncAction should not be called");

@ -20,33 +20,41 @@ import android.database.Cursor;
import org.json.JSONObject;
/**
* ,Google Task
*/
public abstract class Node {
public static final int SYNC_ACTION_NONE = 0;
// 同步动作常量定义
public static final int SYNC_ACTION_NONE = 0; // 无需同步
public static final int SYNC_ACTION_ADD_REMOTE = 1;
public static final int SYNC_ACTION_ADD_REMOTE = 1; // 添加到远程
public static final int SYNC_ACTION_ADD_LOCAL = 2;
public static final int SYNC_ACTION_ADD_LOCAL = 2; // 添加到本地
public static final int SYNC_ACTION_DEL_REMOTE = 3;
public static final int SYNC_ACTION_DEL_REMOTE = 3; // 从远程删除
public static final int SYNC_ACTION_DEL_LOCAL = 4;
public static final int SYNC_ACTION_DEL_LOCAL = 4; // 从本地删除
public static final int SYNC_ACTION_UPDATE_REMOTE = 5;
public static final int SYNC_ACTION_UPDATE_REMOTE = 5; // 更新远程
public static final int SYNC_ACTION_UPDATE_LOCAL = 6;
public static final int SYNC_ACTION_UPDATE_LOCAL = 6; // 更新本地
public static final int SYNC_ACTION_UPDATE_CONFLICT = 7;
public static final int SYNC_ACTION_UPDATE_CONFLICT = 7; // 更新冲突
public static final int SYNC_ACTION_ERROR = 8;
public static final int SYNC_ACTION_ERROR = 8; // 同步错误
private String mGid;
// 节点基本属性
private String mGid; // Google Task ID
private String mName;
private String mName; // 节点名称
private long mLastModified;
private long mLastModified; // 最后修改时间
private boolean mDeleted;
private boolean mDeleted; // 删除标记
/**
* ,
*/
public Node() {
mGid = null;
mName = "";
@ -54,46 +62,105 @@ public abstract class Node {
mDeleted = false;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public abstract JSONObject getCreateAction(int actionId);
/**
* JSON
* @param actionId ID
* @return JSON
*/
public abstract JSONObject getUpdateAction(int actionId);
/**
* JSON
* @param js JSON
*/
public abstract void setContentByRemoteJSON(JSONObject js);
/**
* JSON
* @param js JSON
*/
public abstract void setContentByLocalJSON(JSONObject js);
/**
* JSON
* @return JSON
*/
public abstract JSONObject getLocalJSONFromContent();
/**
*
* @param c
* @return
*/
public abstract int getSyncAction(Cursor c);
/**
* Google Task ID
* @param gid Google Task ID
*/
public void setGid(String gid) {
this.mGid = gid;
}
/**
*
* @param name
*/
public void setName(String name) {
this.mName = name;
}
/**
*
* @param lastModified
*/
public void setLastModified(long lastModified) {
this.mLastModified = lastModified;
}
/**
*
* @param deleted
*/
public void setDeleted(boolean deleted) {
this.mDeleted = deleted;
}
/**
* Google Task ID
* @return Google Task ID
*/
public String getGid() {
return this.mGid;
}
/**
*
* @return
*/
public String getName() {
return this.mName;
}
/**
*
* @return
*/
public long getLastModified() {
return this.mLastModified;
}
/**
*
* @return
*/
public boolean getDeleted() {
return this.mDeleted;
}

@ -36,154 +36,154 @@ import org.json.JSONObject;
public class SqlData {
private static final String TAG = SqlData.class.getSimpleName();
private static final String TAG = SqlData.class.getSimpleName(); // 日志标签
private static final int INVALID_ID = -99999;
private static final int INVALID_ID = -99999; // 无效ID常量
public static final String[] PROJECTION_DATA = new String[] {
DataColumns.ID, DataColumns.MIME_TYPE, DataColumns.CONTENT, DataColumns.DATA1,
DataColumns.DATA3
};
}; // 数据列投影
public static final int DATA_ID_COLUMN = 0;
public static final int DATA_ID_COLUMN = 0; // 数据ID列索引
public static final int DATA_MIME_TYPE_COLUMN = 1;
public static final int DATA_MIME_TYPE_COLUMN = 1; // 数据MIME类型列索引
public static final int DATA_CONTENT_COLUMN = 2;
public static final int DATA_CONTENT_COLUMN = 2; // 数据内容列索引
public static final int DATA_CONTENT_DATA_1_COLUMN = 3;
public static final int DATA_CONTENT_DATA_1_COLUMN = 3; // 数据内容数据1列索引
public static final int DATA_CONTENT_DATA_3_COLUMN = 4;
public static final int DATA_CONTENT_DATA_3_COLUMN = 4; // 数据内容数据3列索引
private ContentResolver mContentResolver;
private ContentResolver mContentResolver; // 内容解析器
private boolean mIsCreate;
private boolean mIsCreate; // 是否为创建标志
private long mDataId;
private long mDataId; // 数据ID
private String mDataMimeType;
private String mDataMimeType; // 数据MIME类型
private String mDataContent;
private String mDataContent; // 数据内容
private long mDataContentData1;
private long mDataContentData1; // 数据内容数据1
private String mDataContentData3;
private String mDataContentData3; // 数据内容数据3
private ContentValues mDiffDataValues;
private ContentValues mDiffDataValues; // 差异数据值
public SqlData(Context context) {
mContentResolver = context.getContentResolver();
mIsCreate = true;
mDataId = INVALID_ID;
mDataMimeType = DataConstants.NOTE;
mDataContent = "";
mDataContentData1 = 0;
mDataContentData3 = "";
mDiffDataValues = new ContentValues();
mContentResolver = context.getContentResolver(); // 获取内容解析器
mIsCreate = true; // 设置为创建标志
mDataId = INVALID_ID; // 初始化数据ID
mDataMimeType = DataConstants.NOTE; // 初始化数据MIME类型
mDataContent = ""; // 初始化数据内容
mDataContentData1 = 0; // 初始化数据内容数据1
mDataContentData3 = ""; // 初始化数据内容数据3
mDiffDataValues = new ContentValues(); // 初始化差异数据值
}
public SqlData(Context context, Cursor c) {
mContentResolver = context.getContentResolver();
mIsCreate = false;
loadFromCursor(c);
mDiffDataValues = new ContentValues();
mContentResolver = context.getContentResolver(); // 获取内容解析器
mIsCreate = false; // 设置为非创建标志
loadFromCursor(c); // 从游标加载数据
mDiffDataValues = new ContentValues(); // 初始化差异数据值
}
private void loadFromCursor(Cursor c) {
mDataId = c.getLong(DATA_ID_COLUMN);
mDataMimeType = c.getString(DATA_MIME_TYPE_COLUMN);
mDataContent = c.getString(DATA_CONTENT_COLUMN);
mDataContentData1 = c.getLong(DATA_CONTENT_DATA_1_COLUMN);
mDataContentData3 = c.getString(DATA_CONTENT_DATA_3_COLUMN);
mDataId = c.getLong(DATA_ID_COLUMN); // 从游标获取数据ID
mDataMimeType = c.getString(DATA_MIME_TYPE_COLUMN); // 从游标获取数据MIME类型
mDataContent = c.getString(DATA_CONTENT_COLUMN); // 从游标获取数据内容
mDataContentData1 = c.getLong(DATA_CONTENT_DATA_1_COLUMN); // 从游标获取数据内容数据1
mDataContentData3 = c.getString(DATA_CONTENT_DATA_3_COLUMN); // 从游标获取数据内容数据3
}
public void setContent(JSONObject js) throws JSONException {
long dataId = js.has(DataColumns.ID) ? js.getLong(DataColumns.ID) : INVALID_ID;
long dataId = js.has(DataColumns.ID) ? js.getLong(DataColumns.ID) : INVALID_ID; // 获取JSON中的数据ID
if (mIsCreate || mDataId != dataId) {
mDiffDataValues.put(DataColumns.ID, dataId);
mDiffDataValues.put(DataColumns.ID, dataId); // 更新差异数据值中的数据ID
}
mDataId = dataId;
mDataId = dataId; // 更新数据ID
String dataMimeType = js.has(DataColumns.MIME_TYPE) ? js.getString(DataColumns.MIME_TYPE)
: DataConstants.NOTE;
: DataConstants.NOTE; // 获取JSON中的数据MIME类型
if (mIsCreate || !mDataMimeType.equals(dataMimeType)) {
mDiffDataValues.put(DataColumns.MIME_TYPE, dataMimeType);
mDiffDataValues.put(DataColumns.MIME_TYPE, dataMimeType); // 更新差异数据值中的数据MIME类型
}
mDataMimeType = dataMimeType;
mDataMimeType = dataMimeType; // 更新数据MIME类型
String dataContent = js.has(DataColumns.CONTENT) ? js.getString(DataColumns.CONTENT) : "";
String dataContent = js.has(DataColumns.CONTENT) ? js.getString(DataColumns.CONTENT) : ""; // 获取JSON中的数据内容
if (mIsCreate || !mDataContent.equals(dataContent)) {
mDiffDataValues.put(DataColumns.CONTENT, dataContent);
mDiffDataValues.put(DataColumns.CONTENT, dataContent); // 更新差异数据值中的数据内容
}
mDataContent = dataContent;
mDataContent = dataContent; // 更新数据内容
long dataContentData1 = js.has(DataColumns.DATA1) ? js.getLong(DataColumns.DATA1) : 0;
long dataContentData1 = js.has(DataColumns.DATA1) ? js.getLong(DataColumns.DATA1) : 0; // 获取JSON中的数据内容数据1
if (mIsCreate || mDataContentData1 != dataContentData1) {
mDiffDataValues.put(DataColumns.DATA1, dataContentData1);
mDiffDataValues.put(DataColumns.DATA1, dataContentData1); // 更新差异数据值中的数据内容数据1
}
mDataContentData1 = dataContentData1;
mDataContentData1 = dataContentData1; // 更新数据内容数据1
String dataContentData3 = js.has(DataColumns.DATA3) ? js.getString(DataColumns.DATA3) : "";
String dataContentData3 = js.has(DataColumns.DATA3) ? js.getString(DataColumns.DATA3) : ""; // 获取JSON中的数据内容数据3
if (mIsCreate || !mDataContentData3.equals(dataContentData3)) {
mDiffDataValues.put(DataColumns.DATA3, dataContentData3);
mDiffDataValues.put(DataColumns.DATA3, dataContentData3); // 更新差异数据值中的数据内容数据3
}
mDataContentData3 = dataContentData3;
mDataContentData3 = dataContentData3; // 更新数据内容数据3
}
public JSONObject getContent() throws JSONException {
if (mIsCreate) {
Log.e(TAG, "it seems that we haven't created this in database yet");
Log.e(TAG, "it seems that we haven't created this in database yet"); // 日志记录错误信息
return null;
}
JSONObject js = new JSONObject();
js.put(DataColumns.ID, mDataId);
js.put(DataColumns.MIME_TYPE, mDataMimeType);
js.put(DataColumns.CONTENT, mDataContent);
js.put(DataColumns.DATA1, mDataContentData1);
js.put(DataColumns.DATA3, mDataContentData3);
return js;
JSONObject js = new JSONObject(); // 创建JSON对象
js.put(DataColumns.ID, mDataId); // 将数据ID放入JSON对象
js.put(DataColumns.MIME_TYPE, mDataMimeType); // 将数据MIME类型放入JSON对象
js.put(DataColumns.CONTENT, mDataContent); // 将数据内容放入JSON对象
js.put(DataColumns.DATA1, mDataContentData1); // 将数据内容数据1放入JSON对象
js.put(DataColumns.DATA3, mDataContentData3); // 将数据内容数据3放入JSON对象
return js; // 返回JSON对象
}
public void commit(long noteId, boolean validateVersion, long version) {
if (mIsCreate) {
if (mDataId == INVALID_ID && mDiffDataValues.containsKey(DataColumns.ID)) {
mDiffDataValues.remove(DataColumns.ID);
mDiffDataValues.remove(DataColumns.ID); // 移除差异数据值中的数据ID
}
mDiffDataValues.put(DataColumns.NOTE_ID, noteId);
Uri uri = mContentResolver.insert(Notes.CONTENT_DATA_URI, mDiffDataValues);
mDiffDataValues.put(DataColumns.NOTE_ID, noteId); // 将笔记ID放入差异数据值
Uri uri = mContentResolver.insert(Notes.CONTENT_DATA_URI, mDiffDataValues); // 插入数据
try {
mDataId = Long.valueOf(uri.getPathSegments().get(1));
mDataId = Long.valueOf(uri.getPathSegments().get(1)); // 获取插入数据的ID
} catch (NumberFormatException e) {
Log.e(TAG, "Get note id error :" + e.toString());
throw new ActionFailureException("create note failed");
Log.e(TAG, "Get note id error :" + e.toString()); // 日志记录错误信息
throw new ActionFailureException("create note failed"); // 抛出操作失败异常
}
} else {
if (mDiffDataValues.size() > 0) {
int result = 0;
if (!validateVersion) {
result = mContentResolver.update(ContentUris.withAppendedId(
Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues, null, null);
Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues, null, null); // 更新数据
} else {
result = mContentResolver.update(ContentUris.withAppendedId(
Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues,
" ? in (SELECT " + NoteColumns.ID + " FROM " + TABLE.NOTE
+ " WHERE " + NoteColumns.VERSION + "=?)", new String[] {
String.valueOf(noteId), String.valueOf(version)
});
}); // 更新数据并验证版本
}
if (result == 0) {
Log.w(TAG, "there is no update. maybe user updates note when syncing");
Log.w(TAG, "there is no update. maybe user updates note when syncing"); // 日志记录警告信息
}
}
}
mDiffDataValues.clear();
mIsCreate = false;
mDiffDataValues.clear(); // 清空差异数据值
mIsCreate = false; // 设置为非创建标志
}
public long getId() {
return mDataId;
return mDataId; // 返回数据ID
}
}

@ -16,6 +16,7 @@
package net.micode.notes.gtask.data;
// 导入所需的Android系统类
import android.appwidget.AppWidgetManager;
import android.content.ContentResolver;
import android.content.ContentValues;
@ -24,6 +25,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.util.Log;
// 导入应用程序相关类
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns;
@ -31,18 +33,21 @@ import net.micode.notes.gtask.exception.ActionFailureException;
import net.micode.notes.tool.GTaskStringUtils;
import net.micode.notes.tool.ResourceParser;
// 导入JSON相关类
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
// 导入Java工具类
import java.util.ArrayList;
public class SqlNote {
private static final String TAG = SqlNote.class.getSimpleName();
private static final String TAG = SqlNote.class.getSimpleName(); // 日志标签
private static final int INVALID_ID = -99999;
private static final int INVALID_ID = -99999; // 无效ID常量
// 笔记表的列名数组,用于数据库查询
public static final String[] PROJECTION_NOTE = new String[] {
NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID,
NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE,
@ -52,76 +57,46 @@ public class SqlNote {
NoteColumns.VERSION
};
public static final int ID_COLUMN = 0;
public static final int ALERTED_DATE_COLUMN = 1;
public static final int BG_COLOR_ID_COLUMN = 2;
public static final int CREATED_DATE_COLUMN = 3;
public static final int HAS_ATTACHMENT_COLUMN = 4;
public static final int MODIFIED_DATE_COLUMN = 5;
public static final int NOTES_COUNT_COLUMN = 6;
public static final int PARENT_ID_COLUMN = 7;
public static final int SNIPPET_COLUMN = 8;
public static final int TYPE_COLUMN = 9;
public static final int WIDGET_ID_COLUMN = 10;
public static final int WIDGET_TYPE_COLUMN = 11;
public static final int SYNC_ID_COLUMN = 12;
public static final int LOCAL_MODIFIED_COLUMN = 13;
public static final int ORIGIN_PARENT_ID_COLUMN = 14;
public static final int GTASK_ID_COLUMN = 15;
public static final int VERSION_COLUMN = 16;
private Context mContext;
private ContentResolver mContentResolver;
private boolean mIsCreate;
private long mId;
private long mAlertDate;
private int mBgColorId;
private long mCreatedDate;
private int mHasAttachment;
private long mModifiedDate;
private long mParentId;
private String mSnippet;
private int mType;
private int mWidgetId;
private int mWidgetType;
private long mOriginParent;
private long mVersion;
private ContentValues mDiffNoteValues;
private ArrayList<SqlData> mDataList;
// 定义各列的索引常量
public static final int ID_COLUMN = 0; // ID列索引
public static final int ALERTED_DATE_COLUMN = 1; // 提醒日期列索引
public static final int BG_COLOR_ID_COLUMN = 2; // 背景颜色ID列索引
public static final int CREATED_DATE_COLUMN = 3; // 创建日期列索引
public static final int HAS_ATTACHMENT_COLUMN = 4; // 是否有附件列索引
public static final int MODIFIED_DATE_COLUMN = 5; // 修改日期列索引
public static final int NOTES_COUNT_COLUMN = 6; // 笔记数量列索引
public static final int PARENT_ID_COLUMN = 7; // 父ID列索引
public static final int SNIPPET_COLUMN = 8; // 摘要列索引
public static final int TYPE_COLUMN = 9; // 类型列索引
public static final int WIDGET_ID_COLUMN = 10; // 小部件ID列索引
public static final int WIDGET_TYPE_COLUMN = 11; // 小部件类型列索引
public static final int SYNC_ID_COLUMN = 12; // 同步ID列索引
public static final int LOCAL_MODIFIED_COLUMN = 13; // 本地修改列索引
public static final int ORIGIN_PARENT_ID_COLUMN = 14; // 原始父ID列索引
public static final int GTASK_ID_COLUMN = 15; // GTask ID列索引
public static final int VERSION_COLUMN = 16; // 版本列索引
// 类的成员变量
private Context mContext; // 上下文对象
private ContentResolver mContentResolver; // 内容解析器
private boolean mIsCreate; // 是否是新建笔记
private long mId; // 笔记ID
private long mAlertDate; // 提醒日期
private int mBgColorId; // 背景颜色ID
private long mCreatedDate; // 创建日期
private int mHasAttachment; // 是否有附件
private long mModifiedDate; // 修改日期
private long mParentId; // 父ID
private String mSnippet; // 摘要
private int mType; // 类型
private int mWidgetId; // 小部件ID
private int mWidgetType; // 小部件类型
private long mOriginParent; // 原始父ID
private long mVersion; // 版本
private ContentValues mDiffNoteValues; // 笔记差异值
private ArrayList<SqlData> mDataList; // 数据列表
// 构造函数,创建新笔记
public SqlNote(Context context) {
mContext = context;
mContentResolver = context.getContentResolver();
@ -143,6 +118,7 @@ public class SqlNote {
mDataList = new ArrayList<SqlData>();
}
// 构造函数,从Cursor加载笔记
public SqlNote(Context context, Cursor c) {
mContext = context;
mContentResolver = context.getContentResolver();
@ -154,6 +130,7 @@ public class SqlNote {
mDiffNoteValues = new ContentValues();
}
// 构造函数,根据ID加载笔记
public SqlNote(Context context, long id) {
mContext = context;
mContentResolver = context.getContentResolver();
@ -166,6 +143,7 @@ public class SqlNote {
}
// 根据ID从数据库加载笔记
private void loadFromCursor(long id) {
Cursor c = null;
try {
@ -185,6 +163,7 @@ public class SqlNote {
}
}
// 从Cursor加载笔记数据
private void loadFromCursor(Cursor c) {
mId = c.getLong(ID_COLUMN);
mAlertDate = c.getLong(ALERTED_DATE_COLUMN);
@ -200,6 +179,7 @@ public class SqlNote {
mVersion = c.getLong(VERSION_COLUMN);
}
// 加载笔记内容数据
private void loadDataContent() {
Cursor c = null;
mDataList.clear();
@ -226,13 +206,14 @@ public class SqlNote {
}
}
// 设置笔记内容
public boolean setContent(JSONObject js) {
try {
JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_SYSTEM) {
Log.w(TAG, "cannot set system folder");
} else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_FOLDER) {
// for folder we can only update the snnipet and type
// 对于文件夹类型,只能更新摘要和类型
String snippet = note.has(NoteColumns.SNIPPET) ? note
.getString(NoteColumns.SNIPPET) : "";
if (mIsCreate || !mSnippet.equals(snippet)) {
@ -247,6 +228,7 @@ public class SqlNote {
}
mType = type;
} else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_NOTE) {
// 对于笔记类型,更新所有相关字段
JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA);
long id = note.has(NoteColumns.ID) ? note.getLong(NoteColumns.ID) : INVALID_ID;
if (mIsCreate || mId != id) {
@ -331,6 +313,7 @@ public class SqlNote {
}
mOriginParent = originParent;
// 更新数据内容
for (int i = 0; i < dataArray.length(); i++) {
JSONObject data = dataArray.getJSONObject(i);
SqlData sqlData = null;
@ -359,6 +342,7 @@ public class SqlNote {
return true;
}
// 获取笔记内容的JSON表示
public JSONObject getContent() {
try {
JSONObject js = new JSONObject();
@ -370,6 +354,7 @@ public class SqlNote {
JSONObject note = new JSONObject();
if (mType == Notes.TYPE_NOTE) {
// 对于笔记类型,添加所有字段
note.put(NoteColumns.ID, mId);
note.put(NoteColumns.ALERTED_DATE, mAlertDate);
note.put(NoteColumns.BG_COLOR_ID, mBgColorId);
@ -384,6 +369,7 @@ public class SqlNote {
note.put(NoteColumns.ORIGIN_PARENT_ID, mOriginParent);
js.put(GTaskStringUtils.META_HEAD_NOTE, note);
// 添加数据内容
JSONArray dataArray = new JSONArray();
for (SqlData sqlData : mDataList) {
JSONObject data = sqlData.getContent();
@ -393,6 +379,7 @@ public class SqlNote {
}
js.put(GTaskStringUtils.META_HEAD_DATA, dataArray);
} else if (mType == Notes.TYPE_FOLDER || mType == Notes.TYPE_SYSTEM) {
// 对于文件夹和系统类型,只添加基本信息
note.put(NoteColumns.ID, mId);
note.put(NoteColumns.TYPE, mType);
note.put(NoteColumns.SNIPPET, mSnippet);
@ -407,41 +394,51 @@ public class SqlNote {
return null;
}
// 设置父ID
public void setParentId(long id) {
mParentId = id;
mDiffNoteValues.put(NoteColumns.PARENT_ID, id);
}
// 设置GTask ID
public void setGtaskId(String gid) {
mDiffNoteValues.put(NoteColumns.GTASK_ID, gid);
}
// 设置同步ID
public void setSyncId(long syncId) {
mDiffNoteValues.put(NoteColumns.SYNC_ID, syncId);
}
// 重置本地修改标记
public void resetLocalModified() {
mDiffNoteValues.put(NoteColumns.LOCAL_MODIFIED, 0);
}
// 获取笔记ID
public long getId() {
return mId;
}
// 获取父ID
public long getParentId() {
return mParentId;
}
// 获取摘要
public String getSnippet() {
return mSnippet;
}
// 判断是否为笔记类型
public boolean isNoteType() {
return mType == Notes.TYPE_NOTE;
}
// 提交笔记更改到数据库
public void commit(boolean validateVersion) {
if (mIsCreate) {
// 创建新笔记
if (mId == INVALID_ID && mDiffNoteValues.containsKey(NoteColumns.ID)) {
mDiffNoteValues.remove(NoteColumns.ID);
}
@ -463,6 +460,7 @@ public class SqlNote {
}
}
} else {
// 更新现有笔记
if (mId <= 0 && mId != Notes.ID_ROOT_FOLDER && mId != Notes.ID_CALL_RECORD_FOLDER) {
Log.e(TAG, "No such note");
throw new IllegalStateException("Try to update note with invalid id");
@ -494,7 +492,7 @@ public class SqlNote {
}
}
// refresh local info
// 刷新本地信息
loadFromCursor(mId);
if (mType == Notes.TYPE_NOTE)
loadDataContent();

@ -31,20 +31,30 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* TaskGoogle Task
*/
public class Task extends Node {
private static final String TAG = Task.class.getSimpleName();
// 任务是否完成
private boolean mCompleted;
// 任务备注
private String mNotes;
// 任务元信息
private JSONObject mMetaInfo;
// 前一个兄弟任务
private Task mPriorSibling;
// 父任务列表
private TaskList mParent;
/**
* ,Task
*/
public Task() {
super();
mCompleted = false;
@ -54,6 +64,11 @@ public class Task extends Node {
mMetaInfo = null;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
@ -103,6 +118,11 @@ public class Task extends Node {
return js;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject();
@ -135,6 +155,10 @@ public class Task extends Node {
return js;
}
/**
* JSON
* @param js JSON
*/
public void setContentByRemoteJSON(JSONObject js) {
if (js != null) {
try {
@ -175,6 +199,10 @@ public class Task extends Node {
}
}
/**
* JSON
* @param js JSON
*/
public void setContentByLocalJSON(JSONObject js) {
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)
|| !js.has(GTaskStringUtils.META_HEAD_DATA)) {
@ -204,6 +232,10 @@ public class Task extends Node {
}
}
/**
* JSON
* @return JSON
*/
public JSONObject getLocalJSONFromContent() {
String name = getName();
try {
@ -247,6 +279,10 @@ public class Task extends Node {
}
}
/**
*
* @param metaData
*/
public void setMetaInfo(MetaData metaData) {
if (metaData != null && metaData.getNotes() != null) {
try {
@ -258,6 +294,11 @@ public class Task extends Node {
}
}
/**
*
* @param c
* @return
*/
public int getSyncAction(Cursor c) {
try {
JSONObject noteInfo = null;
@ -311,39 +352,75 @@ public class Task extends Node {
return SYNC_ACTION_ERROR;
}
/**
*
* @return true,false
*/
public boolean isWorthSaving() {
return mMetaInfo != null || (getName() != null && getName().trim().length() > 0)
|| (getNotes() != null && getNotes().trim().length() > 0);
}
/**
*
* @param completed
*/
public void setCompleted(boolean completed) {
this.mCompleted = completed;
}
/**
*
* @param notes
*/
public void setNotes(String notes) {
this.mNotes = notes;
}
/**
*
* @param priorSibling
*/
public void setPriorSibling(Task priorSibling) {
this.mPriorSibling = priorSibling;
}
/**
*
* @param parent
*/
public void setParent(TaskList parent) {
this.mParent = parent;
}
/**
*
* @return
*/
public boolean getCompleted() {
return this.mCompleted;
}
/**
*
* @return
*/
public String getNotes() {
return this.mNotes;
}
/**
*
* @return
*/
public Task getPriorSibling() {
return this.mPriorSibling;
}
/**
*
* @return
*/
public TaskList getParent() {
return this.mParent;
}

@ -29,35 +29,48 @@ import org.json.JSONObject;
import java.util.ArrayList;
/**
* TaskList,Node
*/
public class TaskList extends Node {
// 日志标签
private static final String TAG = TaskList.class.getSimpleName();
// 任务列表索引
private int mIndex;
// 子任务列表
private ArrayList<Task> mChildren;
/**
* ,TaskList
*/
public TaskList() {
super();
mChildren = new ArrayList<Task>();
mIndex = 1;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
try {
// action_type
// 设置动作类型为创建
js.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_CREATE);
// action_id
// 设置动作ID
js.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, actionId);
// index
// 设置索引
js.put(GTaskStringUtils.GTASK_JSON_INDEX, mIndex);
// entity_delta
// 设置实体数据
JSONObject entity = new JSONObject();
entity.put(GTaskStringUtils.GTASK_JSON_NAME, getName());
entity.put(GTaskStringUtils.GTASK_JSON_CREATOR_ID, "null");
@ -74,21 +87,26 @@ public class TaskList extends Node {
return js;
}
/**
* JSON
* @param actionId ID
* @return JSON
*/
public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject();
try {
// action_type
// 设置动作类型为更新
js.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_UPDATE);
// action_id
// 设置动作ID
js.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, actionId);
// id
// 设置任务列表ID
js.put(GTaskStringUtils.GTASK_JSON_ID, getGid());
// entity_delta
// 设置实体数据
JSONObject entity = new JSONObject();
entity.put(GTaskStringUtils.GTASK_JSON_NAME, getName());
entity.put(GTaskStringUtils.GTASK_JSON_DELETED, getDeleted());
@ -103,20 +121,24 @@ public class TaskList extends Node {
return js;
}
/**
* JSON
* @param js JSON
*/
public void setContentByRemoteJSON(JSONObject js) {
if (js != null) {
try {
// id
// 设置任务列表ID
if (js.has(GTaskStringUtils.GTASK_JSON_ID)) {
setGid(js.getString(GTaskStringUtils.GTASK_JSON_ID));
}
// last_modified
// 设置最后修改时间
if (js.has(GTaskStringUtils.GTASK_JSON_LAST_MODIFIED)) {
setLastModified(js.getLong(GTaskStringUtils.GTASK_JSON_LAST_MODIFIED));
}
// name
// 设置名称
if (js.has(GTaskStringUtils.GTASK_JSON_NAME)) {
setName(js.getString(GTaskStringUtils.GTASK_JSON_NAME));
}
@ -129,6 +151,10 @@ public class TaskList extends Node {
}
}
/**
* JSON
* @param js JSON
*/
public void setContentByLocalJSON(JSONObject js) {
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) {
Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
@ -137,6 +163,7 @@ public class TaskList extends Node {
try {
JSONObject folder = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
// 根据不同类型设置名称
if (folder.getInt(NoteColumns.TYPE) == Notes.TYPE_FOLDER) {
String name = folder.getString(NoteColumns.SNIPPET);
setName(GTaskStringUtils.MIUI_FOLDER_PREFFIX + name);
@ -157,11 +184,16 @@ public class TaskList extends Node {
}
}
/**
* JSON
* @return JSON
*/
public JSONObject getLocalJSONFromContent() {
try {
JSONObject js = new JSONObject();
JSONObject folder = new JSONObject();
// 处理文件夹名称
String folderName = getName();
if (getName().startsWith(GTaskStringUtils.MIUI_FOLDER_PREFFIX))
folderName = folderName.substring(GTaskStringUtils.MIUI_FOLDER_PREFFIX.length(),
@ -183,28 +215,33 @@ public class TaskList extends Node {
}
}
/**
*
* @param c
* @return
*/
public int getSyncAction(Cursor c) {
try {
if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) {
// there is no local update
// 本地未修改
if (c.getLong(SqlNote.SYNC_ID_COLUMN) == getLastModified()) {
// no update both side
// 双方都未更新
return SYNC_ACTION_NONE;
} else {
// apply remote to local
// 应用远程更新到本地
return SYNC_ACTION_UPDATE_LOCAL;
}
} else {
// validate gtask id
// 验证gtask id
if (!c.getString(SqlNote.GTASK_ID_COLUMN).equals(getGid())) {
Log.e(TAG, "gtask id doesn't match");
return SYNC_ACTION_ERROR;
}
if (c.getLong(SqlNote.SYNC_ID_COLUMN) == getLastModified()) {
// local modification only
// 仅本地修改
return SYNC_ACTION_UPDATE_REMOTE;
} else {
// for folder conflicts, just apply local modification
// 对于文件夹冲突,仅应用本地修改
return SYNC_ACTION_UPDATE_REMOTE;
}
}
@ -216,16 +253,25 @@ public class TaskList extends Node {
return SYNC_ACTION_ERROR;
}
/**
*
* @return
*/
public int getChildTaskCount() {
return mChildren.size();
}
/**
*
* @param task
* @return
*/
public boolean addChildTask(Task task) {
boolean ret = false;
if (task != null && !mChildren.contains(task)) {
ret = mChildren.add(task);
if (ret) {
// need to set prior sibling and parent
// 设置前一个兄弟任务和父任务
task.setPriorSibling(mChildren.isEmpty() ? null : mChildren
.get(mChildren.size() - 1));
task.setParent(this);
@ -234,6 +280,12 @@ public class TaskList extends Node {
return ret;
}
/**
*
* @param task
* @param index
* @return
*/
public boolean addChildTask(Task task, int index) {
if (index < 0 || index > mChildren.size()) {
Log.e(TAG, "add child task: invalid index");
@ -244,7 +296,7 @@ public class TaskList extends Node {
if (task != null && pos == -1) {
mChildren.add(index, task);
// update the task list
// 更新任务列表
Task preTask = null;
Task afterTask = null;
if (index != 0)
@ -260,6 +312,11 @@ public class TaskList extends Node {
return true;
}
/**
*
* @param task
* @return
*/
public boolean removeChildTask(Task task) {
boolean ret = false;
int index = mChildren.indexOf(task);
@ -267,11 +324,11 @@ public class TaskList extends Node {
ret = mChildren.remove(task);
if (ret) {
// reset prior sibling and parent
// 重置前一个兄弟任务和父任务
task.setPriorSibling(null);
task.setParent(null);
// update the task list
// 更新任务列表
if (index != mChildren.size()) {
mChildren.get(index).setPriorSibling(
index == 0 ? null : mChildren.get(index - 1));
@ -281,6 +338,12 @@ public class TaskList extends Node {
return ret;
}
/**
*
* @param task
* @param index
* @return
*/
public boolean moveChildTask(Task task, int index) {
if (index < 0 || index >= mChildren.size()) {
@ -299,6 +362,11 @@ public class TaskList extends Node {
return (removeChildTask(task) && addChildTask(task, index));
}
/**
* GID
* @param gid GID
* @return ,null
*/
public Task findChildTaskByGid(String gid) {
for (int i = 0; i < mChildren.size(); i++) {
Task t = mChildren.get(i);
@ -309,10 +377,20 @@ public class TaskList extends Node {
return null;
}
/**
*
* @param task
* @return
*/
public int getChildTaskIndex(Task task) {
return mChildren.indexOf(task);
}
/**
*
* @param index
* @return
*/
public Task getChildTaskByIndex(int index) {
if (index < 0 || index >= mChildren.size()) {
Log.e(TAG, "getTaskByIndex: invalid index");
@ -321,6 +399,11 @@ public class TaskList extends Node {
return mChildren.get(index);
}
/**
* GID
* @param gid GID
* @return
*/
public Task getChilTaskByGid(String gid) {
for (Task task : mChildren) {
if (task.getGid().equals(gid))
@ -329,14 +412,26 @@ public class TaskList extends Node {
return null;
}
/**
*
* @return
*/
public ArrayList<Task> getChildTaskList() {
return this.mChildren;
}
/**
*
* @param index
*/
public void setIndex(int index) {
this.mIndex = index;
}
/**
*
* @return
*/
public int getIndex() {
return this.mIndex;
}

@ -16,17 +16,38 @@
package net.micode.notes.gtask.exception;
/**
* Google Task
* Google Task
*/
public class ActionFailureException extends RuntimeException {
/**
* ID
*/
private static final long serialVersionUID = 4425249765923293627L;
/**
*
* ActionFailureException
*/
public ActionFailureException() {
super();
}
/**
*
* @param paramString
*/
public ActionFailureException(String paramString) {
super(paramString);
}
/**
*
* @param paramString
* @param paramThrowable
*/
public ActionFailureException(String paramString, Throwable paramThrowable) {
super(paramString, paramThrowable);
}

@ -16,17 +16,38 @@
package net.micode.notes.gtask.exception;
/**
*
* Google Task
*/
public class NetworkFailureException extends Exception {
/**
* ID
*/
private static final long serialVersionUID = 2107610287180234136L;
/**
*
* NetworkFailureException
*/
public NetworkFailureException() {
super();
}
/**
*
* @param paramString
*/
public NetworkFailureException(String paramString) {
super(paramString);
}
/**
*
* @param paramString
* @param paramThrowable
*/
public NetworkFailureException(String paramString, Throwable paramThrowable) {
super(paramString, paramThrowable);
}

@ -1,4 +1,3 @@
/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
*
@ -28,23 +27,39 @@ import net.micode.notes.R;
import net.micode.notes.ui.NotesListActivity;
import net.micode.notes.ui.NotesPreferenceActivity;
/**
* Google Task
* Google Task
*/
public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
// 通知ID
private static int GTASK_SYNC_NOTIFICATION_ID = 5234235;
/**
*
*/
public interface OnCompleteListener {
void onComplete();
}
// 上下文对象
private Context mContext;
// 通知管理器
private NotificationManager mNotifiManager;
// Google Task管理器
private GTaskManager mTaskManager;
// 同步完成监听器
private OnCompleteListener mOnCompleteListener;
/**
*
* @param context
* @param listener
*/
public GTaskASyncTask(Context context, OnCompleteListener listener) {
mContext = context;
mOnCompleteListener = listener;
@ -53,16 +68,28 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
mTaskManager = GTaskManager.getInstance();
}
/**
*
*/
public void cancelSync() {
mTaskManager.cancelSync();
}
/**
*
* @param message
*/
public void publishProgess(String message) {
publishProgress(new String[] {
message
});
}
/**
*
* @param tickerId ID
* @param content
*/
private void showNotification(int tickerId, String content) {
PendingIntent pendingIntent;
if (tickerId != R.string.ticker_success) {
@ -74,7 +101,7 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
NotesListActivity.class), 0);
}
// 创建通知
Notification.Builder builder = new Notification.Builder(mContext)
.setAutoCancel(true)
.setContentTitle(mContext.getString(R.string.app_name))
@ -86,7 +113,11 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
}
/**
*
* @param unused 使
* @return
*/
@Override
protected Integer doInBackground(Void... unused) {
publishProgess(mContext.getString(R.string.sync_progress_login, NotesPreferenceActivity
@ -94,6 +125,10 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
return mTaskManager.sync(mContext, this);
}
/**
*
* @param progress
*/
@Override
protected void onProgressUpdate(String... progress) {
showNotification(R.string.ticker_syncing, progress[0]);
@ -102,23 +137,30 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
}
}
/**
*
* @param result
*/
@Override
protected void onPostExecute(Integer result) {
if (result == GTaskManager.STATE_SUCCESS) {
// 同步成功
showNotification(R.string.ticker_success, mContext.getString(
R.string.success_sync_account, mTaskManager.getSyncAccount()));
NotesPreferenceActivity.setLastSyncTime(mContext, System.currentTimeMillis());
} else if (result == GTaskManager.STATE_NETWORK_ERROR) {
// 网络错误
showNotification(R.string.ticker_fail, mContext.getString(R.string.error_sync_network));
} else if (result == GTaskManager.STATE_INTERNAL_ERROR) {
// 内部错误
showNotification(R.string.ticker_fail, mContext.getString(R.string.error_sync_internal));
} else if (result == GTaskManager.STATE_SYNC_CANCELLED) {
// 同步被取消
showNotification(R.string.ticker_cancel, mContext
.getString(R.string.error_sync_cancelled));
}
if (mOnCompleteListener != null) {
new Thread(new Runnable() {
public void run() {
mOnCompleteListener.onComplete();
}

@ -60,36 +60,43 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
/**
* GTaskClientGoogle Tasks
* ,
*/
public class GTaskClient {
private static final String TAG = GTaskClient.class.getSimpleName();
// Google Tasks相关URL常量
private static final String GTASK_URL = "https://mail.google.com/tasks/";
private static final String GTASK_GET_URL = "https://mail.google.com/tasks/ig";
private static final String GTASK_POST_URL = "https://mail.google.com/tasks/r/ig";
// 单例实例
private static GTaskClient mInstance = null;
// HTTP客户端
private DefaultHttpClient mHttpClient;
// 请求URL
private String mGetUrl;
private String mPostUrl;
// 客户端版本号
private long mClientVersion;
// 登录状态相关
private boolean mLoggedin;
private long mLastLoginTime;
private int mActionId;
private Account mAccount;
// 更新数组
private JSONArray mUpdateArray;
/**
* ,
*/
private GTaskClient() {
mHttpClient = null;
mGetUrl = GTASK_GET_URL;
@ -102,6 +109,10 @@ public class GTaskClient {
mUpdateArray = null;
}
/**
* GTaskClient
* @return GTaskClient
*/
public static synchronized GTaskClient getInstance() {
if (mInstance == null) {
mInstance = new GTaskClient();
@ -109,15 +120,19 @@ public class GTaskClient {
return mInstance;
}
/**
* Google
* @param activity Activity
* @return
*/
public boolean login(Activity activity) {
// we suppose that the cookie would expire after 5 minutes
// then we need to re-login
// 检查登录是否过期(5分钟)
final long interval = 1000 * 60 * 5;
if (mLastLoginTime + interval < System.currentTimeMillis()) {
mLoggedin = false;
}
// need to re-login after account switch
// 切换账号后需要重新登录
if (mLoggedin
&& !TextUtils.equals(getSyncAccount().name, NotesPreferenceActivity
.getSyncAccountName(activity))) {
@ -136,7 +151,7 @@ public class GTaskClient {
return false;
}
// login with custom domain if necessary
// 如果是自定义域名,需要特殊处理登录URL
if (!(mAccount.name.toLowerCase().endsWith("gmail.com") || mAccount.name.toLowerCase()
.endsWith("googlemail.com"))) {
StringBuilder url = new StringBuilder(GTASK_URL).append("a/");
@ -151,7 +166,7 @@ public class GTaskClient {
}
}
// try to login with google official url
// 尝试使用官方URL登录
if (!mLoggedin) {
mGetUrl = GTASK_GET_URL;
mPostUrl = GTASK_POST_URL;
@ -164,6 +179,12 @@ public class GTaskClient {
return true;
}
/**
* GoogleToken
* @param activity Activity
* @param invalidateToken 使token
* @return Token
*/
private String loginGoogleAccount(Activity activity, boolean invalidateToken) {
String authToken;
AccountManager accountManager = AccountManager.get(activity);
@ -189,7 +210,7 @@ public class GTaskClient {
return null;
}
// get the token now
// 获取认证Token
AccountManagerFuture<Bundle> accountManagerFuture = accountManager.getAuthToken(account,
"goanna_mobile", null, activity, null, null);
try {
@ -207,10 +228,15 @@ public class GTaskClient {
return authToken;
}
/**
* Google Tasks
* @param activity Activity
* @param authToken Token
* @return
*/
private boolean tryToLoginGtask(Activity activity, String authToken) {
if (!loginGtask(authToken)) {
// maybe the auth token is out of date, now let's invalidate the
// token and try again
// Token可能过期,尝试重新获取Token
authToken = loginGoogleAccount(activity, true);
if (authToken == null) {
Log.e(TAG, "login google account failed");
@ -225,6 +251,11 @@ public class GTaskClient {
return true;
}
/**
* 使TokenGoogle Tasks
* @param authToken Token
* @return
*/
private boolean loginGtask(String authToken) {
int timeoutConnection = 10000;
int timeoutSocket = 15000;
@ -236,14 +267,14 @@ public class GTaskClient {
mHttpClient.setCookieStore(localBasicCookieStore);
HttpProtocolParams.setUseExpectContinue(mHttpClient.getParams(), false);
// login gtask
// 登录Google Tasks
try {
String loginUrl = mGetUrl + "?auth=" + authToken;
HttpGet httpGet = new HttpGet(loginUrl);
HttpResponse response = null;
response = mHttpClient.execute(httpGet);
// get the cookie now
// 获取认证Cookie
List<Cookie> cookies = mHttpClient.getCookieStore().getCookies();
boolean hasAuthCookie = false;
for (Cookie cookie : cookies) {
@ -255,7 +286,7 @@ public class GTaskClient {
Log.w(TAG, "it seems that there is no auth cookie");
}
// get the client version
// 获取客户端版本号
String resString = getResponseContent(response.getEntity());
String jsBegin = "_setup(";
String jsEnd = ")}</script>";
@ -272,7 +303,6 @@ public class GTaskClient {
e.printStackTrace();
return false;
} catch (Exception e) {
// simply catch all exceptions
Log.e(TAG, "httpget gtask_url failed");
return false;
}
@ -280,10 +310,18 @@ public class GTaskClient {
return true;
}
/**
* ID
* @return ID
*/
private int getActionId() {
return mActionId++;
}
/**
* HTTP POST
* @return HttpPost
*/
private HttpPost createHttpPost() {
HttpPost httpPost = new HttpPost(mPostUrl);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
@ -291,6 +329,12 @@ public class GTaskClient {
return httpPost;
}
/**
* HTTP
* @param entity HTTP
* @return
* @throws IOException IO
*/
private String getResponseContent(HttpEntity entity) throws IOException {
String contentEncoding = null;
if (entity.getContentEncoding() != null) {
@ -323,6 +367,12 @@ public class GTaskClient {
}
}
/**
* POST
* @param js JSON
* @return JSON
* @throws NetworkFailureException
*/
private JSONObject postRequest(JSONObject js) throws NetworkFailureException {
if (!mLoggedin) {
Log.e(TAG, "please login first");
@ -336,7 +386,7 @@ public class GTaskClient {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8");
httpPost.setEntity(entity);
// execute the post
// 执行POST请求
HttpResponse response = mHttpClient.execute(httpPost);
String jsString = getResponseContent(response.getEntity());
return new JSONObject(jsString);
@ -360,20 +410,25 @@ public class GTaskClient {
}
}
/**
*
* @param task
* @throws NetworkFailureException
*/
public void createTask(Task task) throws NetworkFailureException {
commitUpdate();
try {
JSONObject jsPost = new JSONObject();
JSONArray actionList = new JSONArray();
// action_list
// 构建action_list
actionList.put(task.getCreateAction(getActionId()));
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
// client_version
// 添加client_version
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
// post
// 发送请求
JSONObject jsResponse = postRequest(jsPost);
JSONObject jsResult = (JSONObject) jsResponse.getJSONArray(
GTaskStringUtils.GTASK_JSON_RESULTS).get(0);
@ -386,20 +441,25 @@ public class GTaskClient {
}
}
/**
*
* @param tasklist
* @throws NetworkFailureException
*/
public void createTaskList(TaskList tasklist) throws NetworkFailureException {
commitUpdate();
try {
JSONObject jsPost = new JSONObject();
JSONArray actionList = new JSONArray();
// action_list
// 构建action_list
actionList.put(tasklist.getCreateAction(getActionId()));
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
// client version
// 添加client version
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
// post
// 发送请求
JSONObject jsResponse = postRequest(jsPost);
JSONObject jsResult = (JSONObject) jsResponse.getJSONArray(
GTaskStringUtils.GTASK_JSON_RESULTS).get(0);
@ -412,15 +472,19 @@ public class GTaskClient {
}
}
/**
*
* @throws NetworkFailureException
*/
public void commitUpdate() throws NetworkFailureException {
if (mUpdateArray != null) {
try {
JSONObject jsPost = new JSONObject();
// action_list
// 添加action_list
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, mUpdateArray);
// client_version
// 添加client_version
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
postRequest(jsPost);
@ -433,10 +497,14 @@ public class GTaskClient {
}
}
/**
*
* @param node
* @throws NetworkFailureException
*/
public void addUpdateNode(Node node) throws NetworkFailureException {
if (node != null) {
// too many update items may result in an error
// set max to 10 items
// 更新项过多可能导致错误,最多10项
if (mUpdateArray != null && mUpdateArray.length() > 10) {
commitUpdate();
}
@ -447,6 +515,13 @@ public class GTaskClient {
}
}
/**
*
* @param task
* @param preParent
* @param curParent
* @throws NetworkFailureException
*/
public void moveTask(Task task, TaskList preParent, TaskList curParent)
throws NetworkFailureException {
commitUpdate();
@ -455,26 +530,25 @@ public class GTaskClient {
JSONArray actionList = new JSONArray();
JSONObject action = new JSONObject();
// action_list
// 构建action_list
action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_MOVE);
action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId());
action.put(GTaskStringUtils.GTASK_JSON_ID, task.getGid());
if (preParent == curParent && task.getPriorSibling() != null) {
// put prioring_sibing_id only if moving within the tasklist and
// it is not the first one
// 仅当在同一任务列表内移动且不是第一个时添加prior_sibling_id
action.put(GTaskStringUtils.GTASK_JSON_PRIOR_SIBLING_ID, task.getPriorSibling());
}
action.put(GTaskStringUtils.GTASK_JSON_SOURCE_LIST, preParent.getGid());
action.put(GTaskStringUtils.GTASK_JSON_DEST_PARENT, curParent.getGid());
if (preParent != curParent) {
// put the dest_list only if moving between tasklists
// 仅当在不同任务列表间移动时添加dest_list
action.put(GTaskStringUtils.GTASK_JSON_DEST_LIST, curParent.getGid());
}
actionList.put(action);
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
// client_version
// 添加client_version
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
postRequest(jsPost);
@ -486,18 +560,23 @@ public class GTaskClient {
}
}
/**
*
* @param node
* @throws NetworkFailureException
*/
public void deleteNode(Node node) throws NetworkFailureException {
commitUpdate();
try {
JSONObject jsPost = new JSONObject();
JSONArray actionList = new JSONArray();
// action_list
// 构建action_list
node.setDeleted(true);
actionList.put(node.getUpdateAction(getActionId()));
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
// client_version
// 添加client_version
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
postRequest(jsPost);
@ -509,6 +588,11 @@ public class GTaskClient {
}
}
/**
*
* @return JSON
* @throws NetworkFailureException
*/
public JSONArray getTaskLists() throws NetworkFailureException {
if (!mLoggedin) {
Log.e(TAG, "please login first");
@ -520,7 +604,7 @@ public class GTaskClient {
HttpResponse response = null;
response = mHttpClient.execute(httpGet);
// get the task list
// 获取任务列表
String resString = getResponseContent(response.getEntity());
String jsBegin = "_setup(";
String jsEnd = ")}</script>";
@ -547,6 +631,12 @@ public class GTaskClient {
}
}
/**
*
* @param listGid ID
* @return JSON
* @throws NetworkFailureException
*/
public JSONArray getTaskList(String listGid) throws NetworkFailureException {
commitUpdate();
try {
@ -554,7 +644,7 @@ public class GTaskClient {
JSONArray actionList = new JSONArray();
JSONObject action = new JSONObject();
// action_list
// 构建action_list
action.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE,
GTaskStringUtils.GTASK_JSON_ACTION_TYPE_GETALL);
action.put(GTaskStringUtils.GTASK_JSON_ACTION_ID, getActionId());
@ -563,7 +653,7 @@ public class GTaskClient {
actionList.put(action);
jsPost.put(GTaskStringUtils.GTASK_JSON_ACTION_LIST, actionList);
// client_version
// 添加client_version
jsPost.put(GTaskStringUtils.GTASK_JSON_CLIENT_VERSION, mClientVersion);
JSONObject jsResponse = postRequest(jsPost);
@ -575,10 +665,17 @@ public class GTaskClient {
}
}
/**
*
* @return
*/
public Account getSyncAccount() {
return mAccount;
}
/**
*
*/
public void resetUpdateArray() {
mUpdateArray = null;
}

@ -47,46 +47,41 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
/**
* GTaskManagerGoogle Tasks
* Google Tasks
*/
public class GTaskManager {
private static final String TAG = GTaskManager.class.getSimpleName();
public static final int STATE_SUCCESS = 0;
public static final int STATE_NETWORK_ERROR = 1;
public static final int STATE_INTERNAL_ERROR = 2;
public static final int STATE_SYNC_IN_PROGRESS = 3;
public static final int STATE_SYNC_CANCELLED = 4;
private static GTaskManager mInstance = null;
private Activity mActivity;
private Context mContext;
private ContentResolver mContentResolver;
private boolean mSyncing;
private boolean mCancelled;
private HashMap<String, TaskList> mGTaskListHashMap;
private HashMap<String, Node> mGTaskHashMap;
private HashMap<String, MetaData> mMetaHashMap;
private TaskList mMetaList;
private HashSet<Long> mLocalDeleteIdMap;
private HashMap<String, Long> mGidToNid;
private HashMap<Long, String> mNidToGid;
// 同步状态码定义
public static final int STATE_SUCCESS = 0; // 同步成功
public static final int STATE_NETWORK_ERROR = 1; // 网络错误
public static final int STATE_INTERNAL_ERROR = 2; // 内部错误
public static final int STATE_SYNC_IN_PROGRESS = 3; // 同步进行中
public static final int STATE_SYNC_CANCELLED = 4; // 同步被取消
private static GTaskManager mInstance = null; // 单例实例
private Activity mActivity; // 用于获取认证Token的Activity
private Context mContext; // 应用上下文
private ContentResolver mContentResolver; // 内容解析器
private boolean mSyncing; // 是否正在同步
private boolean mCancelled; // 是否取消同步
// 数据结构用于存储同步状态
private HashMap<String, TaskList> mGTaskListHashMap; // 任务列表映射
private HashMap<String, Node> mGTaskHashMap; // 任务节点映射
private HashMap<String, MetaData> mMetaHashMap; // 元数据映射
private TaskList mMetaList; // 元数据列表
private HashSet<Long> mLocalDeleteIdMap; // 本地删除ID集合
private HashMap<String, Long> mGidToNid; // Google ID到本地Note ID的映射
private HashMap<Long, String> mNidToGid; // 本地Note ID到Google ID的映射
/**
* ,
*/
private GTaskManager() {
mSyncing = false;
mCancelled = false;
@ -99,6 +94,9 @@ public class GTaskManager {
mNidToGid = new HashMap<Long, String>();
}
/**
* GTaskManager
*/
public static synchronized GTaskManager getInstance() {
if (mInstance == null) {
mInstance = new GTaskManager();
@ -106,11 +104,19 @@ public class GTaskManager {
return mInstance;
}
/**
* Activity,Token
*/
public synchronized void setActivityContext(Activity activity) {
// used for getting authtoken
mActivity = activity;
}
/**
*
* @param context
* @param asyncTask
* @return
*/
public int sync(Context context, GTaskASyncTask asyncTask) {
if (mSyncing) {
Log.d(TAG, "Sync is in progress");
@ -131,18 +137,18 @@ public class GTaskManager {
GTaskClient client = GTaskClient.getInstance();
client.resetUpdateArray();
// login google task
// 登录Google Tasks
if (!mCancelled) {
if (!client.login(mActivity)) {
throw new NetworkFailureException("login google task failed");
}
}
// get the task list from google
// 从Google获取任务列表
asyncTask.publishProgess(mContext.getString(R.string.sync_progress_init_list));
initGTaskList();
// do content sync work
// 执行内容同步
asyncTask.publishProgess(mContext.getString(R.string.sync_progress_syncing));
syncContent();
} catch (NetworkFailureException e) {
@ -168,6 +174,10 @@ public class GTaskManager {
return mCancelled ? STATE_SYNC_CANCELLED : STATE_SUCCESS;
}
/**
* Google Tasks
*
*/
private void initGTaskList() throws NetworkFailureException {
if (mCancelled)
return;
@ -175,7 +185,7 @@ public class GTaskManager {
try {
JSONArray jsTaskLists = client.getTaskLists();
// init meta list first
// 首先初始化元数据列表
mMetaList = null;
for (int i = 0; i < jsTaskLists.length(); i++) {
JSONObject object = jsTaskLists.getJSONObject(i);
@ -187,7 +197,7 @@ public class GTaskManager {
mMetaList = new TaskList();
mMetaList.setContentByRemoteJSON(object);
// load meta data
// 加载元数据
JSONArray jsMetas = client.getTaskList(gid);
for (int j = 0; j < jsMetas.length(); j++) {
object = (JSONObject) jsMetas.getJSONObject(j);
@ -203,7 +213,7 @@ public class GTaskManager {
}
}
// create meta list if not existed
// 如果元数据列表不存在则创建
if (mMetaList == null) {
mMetaList = new TaskList();
mMetaList.setName(GTaskStringUtils.MIUI_FOLDER_PREFFIX
@ -211,7 +221,7 @@ public class GTaskManager {
GTaskClient.getInstance().createTaskList(mMetaList);
}
// init task list
// 初始化任务列表
for (int i = 0; i < jsTaskLists.length(); i++) {
JSONObject object = jsTaskLists.getJSONObject(i);
String gid = object.getString(GTaskStringUtils.GTASK_JSON_ID);
@ -225,7 +235,7 @@ public class GTaskManager {
mGTaskListHashMap.put(gid, tasklist);
mGTaskHashMap.put(gid, tasklist);
// load tasks
// 加载任务
JSONArray jsTasks = client.getTaskList(gid);
for (int j = 0; j < jsTasks.length(); j++) {
object = (JSONObject) jsTasks.getJSONObject(j);
@ -247,6 +257,10 @@ public class GTaskManager {
}
}
/**
*
*
*/
private void syncContent() throws NetworkFailureException {
int syncType;
Cursor c = null;
@ -259,7 +273,7 @@ public class GTaskManager {
return;
}
// for local deleted note
// 处理本地已删除的笔记
try {
c = mContentResolver.query(Notes.CONTENT_NOTE_URI, SqlNote.PROJECTION_NOTE,
"(type<>? AND parent_id=?)", new String[] {
@ -286,10 +300,10 @@ public class GTaskManager {
}
}
// sync folder first
// 先同步文件夹
syncFolder();
// for note existing in database
// 处理数据库中已存在的笔记
try {
c = mContentResolver.query(Notes.CONTENT_NOTE_URI, SqlNote.PROJECTION_NOTE,
"(type=? AND parent_id<>?)", new String[] {
@ -306,10 +320,10 @@ public class GTaskManager {
syncType = node.getSyncAction(c);
} else {
if (c.getString(SqlNote.GTASK_ID_COLUMN).trim().length() == 0) {
// local add
// 本地新增
syncType = Node.SYNC_ACTION_ADD_REMOTE;
} else {
// remote delete
// 远程删除
syncType = Node.SYNC_ACTION_DEL_LOCAL;
}
}
@ -326,7 +340,7 @@ public class GTaskManager {
}
}
// go through remaining items
// 处理剩余项目
Iterator<Map.Entry<String, Node>> iter = mGTaskHashMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, Node> entry = iter.next();
@ -334,16 +348,15 @@ public class GTaskManager {
doContentSync(Node.SYNC_ACTION_ADD_LOCAL, node, null);
}
// mCancelled can be set by another thread, so we neet to check one by
// one
// clear local delete table
// mCancelled可能被其他线程设置,需要逐个检查
// 清理本地删除表
if (!mCancelled) {
if (!DataUtils.batchDeleteNotes(mContentResolver, mLocalDeleteIdMap)) {
throw new ActionFailureException("failed to batch-delete local deleted notes");
}
}
// refresh local sync id
// 刷新本地同步ID
if (!mCancelled) {
GTaskClient.getInstance().commitUpdate();
refreshLocalSyncId();
@ -351,6 +364,10 @@ public class GTaskManager {
}
/**
*
*
*/
private void syncFolder() throws NetworkFailureException {
Cursor c = null;
String gid;
@ -361,7 +378,7 @@ public class GTaskManager {
return;
}
// for root folder
// 处理根文件夹
try {
c = mContentResolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI,
Notes.ID_ROOT_FOLDER), SqlNote.PROJECTION_NOTE, null, null, null);
@ -373,7 +390,7 @@ public class GTaskManager {
mGTaskHashMap.remove(gid);
mGidToNid.put(gid, (long) Notes.ID_ROOT_FOLDER);
mNidToGid.put((long) Notes.ID_ROOT_FOLDER, gid);
// for system folder, only update remote name if necessary
// 对于系统文件夹,仅在必要时更新远程名称
if (!node.getName().equals(
GTaskStringUtils.MIUI_FOLDER_PREFFIX + GTaskStringUtils.FOLDER_DEFAULT))
doContentSync(Node.SYNC_ACTION_UPDATE_REMOTE, node, c);
@ -390,7 +407,7 @@ public class GTaskManager {
}
}
// for call-note folder
// 处理通话记录文件夹
try {
c = mContentResolver.query(Notes.CONTENT_NOTE_URI, SqlNote.PROJECTION_NOTE, "(_id=?)",
new String[] {
@ -404,8 +421,7 @@ public class GTaskManager {
mGTaskHashMap.remove(gid);
mGidToNid.put(gid, (long) Notes.ID_CALL_RECORD_FOLDER);
mNidToGid.put((long) Notes.ID_CALL_RECORD_FOLDER, gid);
// for system folder, only update remote name if
// necessary
// 对于系统文件夹,仅在必要时更新远程名称
if (!node.getName().equals(
GTaskStringUtils.MIUI_FOLDER_PREFFIX
+ GTaskStringUtils.FOLDER_CALL_NOTE))
@ -424,7 +440,7 @@ public class GTaskManager {
}
}
// for local existing folders
// 处理本地已存在的文件夹
try {
c = mContentResolver.query(Notes.CONTENT_NOTE_URI, SqlNote.PROJECTION_NOTE,
"(type=? AND parent_id<>?)", new String[] {
@ -441,10 +457,10 @@ public class GTaskManager {
syncType = node.getSyncAction(c);
} else {
if (c.getString(SqlNote.GTASK_ID_COLUMN).trim().length() == 0) {
// local add
// 本地新增
syncType = Node.SYNC_ACTION_ADD_REMOTE;
} else {
// remote delete
// 远程删除
syncType = Node.SYNC_ACTION_DEL_LOCAL;
}
}
@ -460,7 +476,7 @@ public class GTaskManager {
}
}
// for remote add folders
// 处理远程新增的文件夹
Iterator<Map.Entry<String, TaskList>> iter = mGTaskListHashMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, TaskList> entry = iter.next();
@ -476,6 +492,12 @@ public class GTaskManager {
GTaskClient.getInstance().commitUpdate();
}
/**
*
* @param syncType
* @param node
* @param c
*/
private void doContentSync(int syncType, Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) {
return;
@ -510,18 +532,22 @@ public class GTaskManager {
updateRemoteNode(node, c);
break;
case Node.SYNC_ACTION_UPDATE_CONFLICT:
// merging both modifications maybe a good idea
// right now just use local update simply
// 合并双方的修改可能是个好主意
// 目前简单使用本地更新
updateRemoteNode(node, c);
break;
case Node.SYNC_ACTION_NONE:
break;
case Node.SYNC_ACTION_ERROR:
default:
throw new ActionFailureException("unkown sync action type");
throw new ActionFailureException("unknown sync action type");
}
}
/**
*
* @param node
*/
private void addLocalNode(Node node) throws NetworkFailureException {
if (mCancelled) {
return;
@ -549,7 +575,7 @@ public class GTaskManager {
if (note.has(NoteColumns.ID)) {
long id = note.getLong(NoteColumns.ID);
if (DataUtils.existInNoteDatabase(mContentResolver, id)) {
// the id is not available, have to create a new one
// ID不可用,需要创建新的
note.remove(NoteColumns.ID);
}
}
@ -562,8 +588,7 @@ public class GTaskManager {
if (data.has(DataColumns.ID)) {
long dataId = data.getLong(DataColumns.ID);
if (DataUtils.existInDataDatabase(mContentResolver, dataId)) {
// the data id is not available, have to create
// a new one
// 数据ID不可用,需要创建新的
data.remove(DataColumns.ID);
}
}
@ -584,25 +609,30 @@ public class GTaskManager {
sqlNote.setParentId(parentId.longValue());
}
// create the local node
// 创建本地节点
sqlNote.setGtaskId(node.getGid());
sqlNote.commit(false);
// update gid-nid mapping
// 更新gid-nid映射
mGidToNid.put(node.getGid(), sqlNote.getId());
mNidToGid.put(sqlNote.getId(), node.getGid());
// update meta
// 更新元数据
updateRemoteMeta(node.getGid(), sqlNote);
}
/**
*
* @param node
* @param c
*/
private void updateLocalNode(Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) {
return;
}
SqlNote sqlNote;
// update the note locally
// 在本地更新笔记
sqlNote = new SqlNote(mContext, c);
sqlNote.setContent(node.getLocalJSONFromContent());
@ -615,10 +645,15 @@ public class GTaskManager {
sqlNote.setParentId(parentId.longValue());
sqlNote.commit(true);
// update meta info
// 更新元数据信息
updateRemoteMeta(node.getGid(), sqlNote);
}
/**
*
* @param node
* @param c
*/
private void addRemoteNode(Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) {
return;
@ -627,7 +662,7 @@ public class GTaskManager {
SqlNote sqlNote = new SqlNote(mContext, c);
Node n;
// update remotely
// 远程更新
if (sqlNote.isNoteType()) {
Task task = new Task();
task.setContentByLocalJSON(sqlNote.getContent());
@ -642,12 +677,12 @@ public class GTaskManager {
GTaskClient.getInstance().createTask(task);
n = (Node) task;
// add meta
// 添加元数据
updateRemoteMeta(task.getGid(), sqlNote);
} else {
TaskList tasklist = null;
// we need to skip folder if it has already existed
// 如果文件夹已存在则需要跳过
String folderName = GTaskStringUtils.MIUI_FOLDER_PREFFIX;
if (sqlNote.getId() == Notes.ID_ROOT_FOLDER)
folderName += GTaskStringUtils.FOLDER_DEFAULT;
@ -671,7 +706,7 @@ public class GTaskManager {
}
}
// no match we can add now
// 没有匹配项则可以添加
if (tasklist == null) {
tasklist = new TaskList();
tasklist.setContentByLocalJSON(sqlNote.getContent());
@ -681,17 +716,22 @@ public class GTaskManager {
n = (Node) tasklist;
}
// update local note
// 更新本地笔记
sqlNote.setGtaskId(n.getGid());
sqlNote.commit(false);
sqlNote.resetLocalModified();
sqlNote.commit(true);
// gid-id mapping
// gid-id映射
mGidToNid.put(n.getGid(), sqlNote.getId());
mNidToGid.put(sqlNote.getId(), n.getGid());
}
/**
*
* @param node
* @param c
*/
private void updateRemoteNode(Node node, Cursor c) throws NetworkFailureException {
if (mCancelled) {
return;

@ -23,25 +23,42 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
/**
* Google Tasks
* Google Tasks,
*/
public class GTaskSyncService extends Service {
/** Intent中同步动作的键名 */
public final static String ACTION_STRING_NAME = "sync_action_type";
/** 开始同步的动作值 */
public final static int ACTION_START_SYNC = 0;
/** 取消同步的动作值 */
public final static int ACTION_CANCEL_SYNC = 1;
/** 无效动作值 */
public final static int ACTION_INVALID = 2;
/** 广播Action名称 */
public final static String GTASK_SERVICE_BROADCAST_NAME = "net.micode.notes.gtask.remote.gtask_sync_service";
/** 广播Extra:是否正在同步 */
public final static String GTASK_SERVICE_BROADCAST_IS_SYNCING = "isSyncing";
/** 广播Extra:同步进度信息 */
public final static String GTASK_SERVICE_BROADCAST_PROGRESS_MSG = "progressMsg";
/** 异步同步任务实例 */
private static GTaskASyncTask mSyncTask = null;
/** 同步进度信息 */
private static String mSyncProgress = "";
/**
*
* ,
*/
private void startSync() {
if (mSyncTask == null) {
mSyncTask = new GTaskASyncTask(this, new GTaskASyncTask.OnCompleteListener() {
@ -56,17 +73,32 @@ public class GTaskSyncService extends Service {
}
}
/**
*
*/
private void cancelSync() {
if (mSyncTask != null) {
mSyncTask.cancelSync();
}
}
/**
* Service
*
*/
@Override
public void onCreate() {
mSyncTask = null;
}
/**
* Service
* Intent
* @param intent Intent
* @param flags
* @param startId ID
* @return
*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Bundle bundle = intent.getExtras();
@ -86,6 +118,10 @@ public class GTaskSyncService extends Service {
return super.onStartCommand(intent, flags, startId);
}
/**
*
*
*/
@Override
public void onLowMemory() {
if (mSyncTask != null) {
@ -93,10 +129,18 @@ public class GTaskSyncService extends Service {
}
}
/**
* Service
* ,null
*/
public IBinder onBind(Intent intent) {
return null;
}
/**
* 广
* @param msg
*/
public void sendBroadcast(String msg) {
mSyncProgress = msg;
Intent intent = new Intent(GTASK_SERVICE_BROADCAST_NAME);
@ -105,6 +149,10 @@ public class GTaskSyncService extends Service {
sendBroadcast(intent);
}
/**
* :
* @param activity Activity
*/
public static void startSync(Activity activity) {
GTaskManager.getInstance().setActivityContext(activity);
Intent intent = new Intent(activity, GTaskSyncService.class);
@ -112,16 +160,28 @@ public class GTaskSyncService extends Service {
activity.startService(intent);
}
/**
* :
* @param context
*/
public static void cancelSync(Context context) {
Intent intent = new Intent(context, GTaskSyncService.class);
intent.putExtra(GTaskSyncService.ACTION_STRING_NAME, GTaskSyncService.ACTION_CANCEL_SYNC);
context.startService(intent);
}
/**
* :
* @return
*/
public static boolean isSyncing() {
return mSyncTask != null;
}
/**
* :
* @return
*/
public static String getProgressString() {
return mSyncProgress;
}

@ -62,8 +62,12 @@
<item name="android:actionBarStyle">@style/NoteActionBarStyle</item>
</style>
<!-- <style name="NoteActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">-->
<!-- <item name="android:displayOptions" />-->
<!-- <item name="android:visibility">gone</item>-->
<!-- </style>-->
<style name="NoteActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:displayOptions" />
<item name="android:visibility">gone</item>
<!-- <item name="android:displayOptions" />-->
<item name="android:visibility">visible</item>
</style>
</resources>
Loading…
Cancel
Save