Ver código fonte

Apex Mobile 新版本

Ray Zhang 8 anos atrás
pai
commit
c82692d4fc
100 arquivos alterados com 13219 adições e 0 exclusões
  1. 19 0
      Apex Mobile/Apex Mobile.iml
  2. 188 0
      Apex Mobile/app/app.iml
  3. 49 0
      Apex Mobile/app/build.gradle
  4. BIN
      Apex Mobile/app/libs/baidumapapi_base_v3_7_1.jar
  5. BIN
      Apex Mobile/app/libs/baidumapapi_map_v3_7_1.jar
  6. BIN
      Apex Mobile/app/libs/core-2.3.0.jar
  7. BIN
      Apex Mobile/app/libs/httpmime-4.1.1.jar
  8. 21 0
      Apex Mobile/app/lint.xml
  9. 40 0
      Apex Mobile/app/proguard-project.txt
  10. 309 0
      Apex Mobile/app/src/main/AndroidManifest.xml
  11. 72 0
      Apex Mobile/app/src/main/java/com/usai/apex/AboutActivity.java
  12. 362 0
      Apex Mobile/app/src/main/java/com/usai/apex/Alarmreceiver.java
  13. 424 0
      Apex Mobile/app/src/main/java/com/usai/apex/AnnouncementActivity.java
  14. 217 0
      Apex Mobile/app/src/main/java/com/usai/apex/ApexActivity.java
  15. 51 0
      Apex Mobile/app/src/main/java/com/usai/apex/ApexBackgroundService.java
  16. 43 0
      Apex Mobile/app/src/main/java/com/usai/apex/ApexHistoryActivity.java
  17. 25 0
      Apex Mobile/app/src/main/java/com/usai/apex/ApexPushService.java
  18. 237 0
      Apex Mobile/app/src/main/java/com/usai/apex/ApexTrackingApplication.java
  19. 616 0
      Apex Mobile/app/src/main/java/com/usai/apex/BaiduMapFragment.java
  20. 55 0
      Apex Mobile/app/src/main/java/com/usai/apex/BootBroadcastReceiver.java
  21. 329 0
      Apex Mobile/app/src/main/java/com/usai/apex/ChangePasswordActivity.java
  22. 329 0
      Apex Mobile/app/src/main/java/com/usai/apex/CustomizeFieldsActivity.java
  23. 411 0
      Apex Mobile/app/src/main/java/com/usai/apex/DetailActivity.java
  24. 712 0
      Apex Mobile/app/src/main/java/com/usai/apex/DetailFragment.java
  25. 25 0
      Apex Mobile/app/src/main/java/com/usai/apex/DocumentsActivity.java
  26. 88 0
      Apex Mobile/app/src/main/java/com/usai/apex/DocumentsFragment.java
  27. 282 0
      Apex Mobile/app/src/main/java/com/usai/apex/DragListView.java
  28. 267 0
      Apex Mobile/app/src/main/java/com/usai/apex/FavoritesFragment.java
  29. 410 0
      Apex Mobile/app/src/main/java/com/usai/apex/FunctionSelectActivity.java
  30. 48 0
      Apex Mobile/app/src/main/java/com/usai/apex/HelpActivity.java
  31. 289 0
      Apex Mobile/app/src/main/java/com/usai/apex/HistoryFragment.java
  32. 185 0
      Apex Mobile/app/src/main/java/com/usai/apex/InnerMapActivity.java
  33. 35 0
      Apex Mobile/app/src/main/java/com/usai/apex/InnerToolsActivity.java
  34. 203 0
      Apex Mobile/app/src/main/java/com/usai/apex/LocalDocumentActivity.java
  35. 29 0
      Apex Mobile/app/src/main/java/com/usai/apex/LocationDetail.java
  36. 174 0
      Apex Mobile/app/src/main/java/com/usai/apex/LocationDetailActivity.java
  37. 434 0
      Apex Mobile/app/src/main/java/com/usai/apex/LoginFragment.java
  38. 370 0
      Apex Mobile/app/src/main/java/com/usai/apex/MessageActivity.java
  39. 424 0
      Apex Mobile/app/src/main/java/com/usai/apex/MessageDetailActivity.java
  40. 870 0
      Apex Mobile/app/src/main/java/com/usai/apex/ResultActivity.java
  41. 384 0
      Apex Mobile/app/src/main/java/com/usai/apex/RetrievePasswordActivity.java
  42. 411 0
      Apex Mobile/app/src/main/java/com/usai/apex/SearchActivity.java
  43. 159 0
      Apex Mobile/app/src/main/java/com/usai/apex/SearchHistoryActivity.java
  44. 556 0
      Apex Mobile/app/src/main/java/com/usai/apex/SearchListActivity.java
  45. 78 0
      Apex Mobile/app/src/main/java/com/usai/apex/SearchResult.java
  46. 66 0
      Apex Mobile/app/src/main/java/com/usai/apex/ServiceLocationFragment.java
  47. 371 0
      Apex Mobile/app/src/main/java/com/usai/apex/SettingsActivity.java
  48. 250 0
      Apex Mobile/app/src/main/java/com/usai/apex/ToolsFragment.java
  49. 36 0
      Apex Mobile/app/src/main/java/com/usai/apex/WebActivity.java
  50. 133 0
      Apex Mobile/app/src/main/java/com/usai/util/Crypto.java
  51. 1411 0
      Apex Mobile/app/src/main/java/com/usai/util/Network.java
  52. 96 0
      Apex Mobile/app/src/main/java/com/usai/util/SqlOpenHelper.java
  53. 54 0
      Apex Mobile/app/src/main/java/com/usai/util/commonUtil.java
  54. 383 0
      Apex Mobile/app/src/main/java/com/usai/util/dbUtil.java
  55. 119 0
      Apex Mobile/app/src/main/java/com/usai/util/dbgUtil.java
  56. 8 0
      Apex Mobile/app/src/main/java/com/usai/util/package-info.java
  57. BIN
      Apex Mobile/app/src/main/res/drawable-hdpi/bg_4.png
  58. BIN
      Apex Mobile/app/src/main/res/drawable-hdpi/ic_launcher.png
  59. BIN
      Apex Mobile/app/src/main/res/drawable-hdpi/ic_marker.png
  60. BIN
      Apex Mobile/app/src/main/res/drawable-hdpi/ic_test.png
  61. BIN
      Apex Mobile/app/src/main/res/drawable-ldpi/ic_test.png
  62. BIN
      Apex Mobile/app/src/main/res/drawable-mdpi/ic_launcher.png
  63. BIN
      Apex Mobile/app/src/main/res/drawable-mdpi/ic_test.png
  64. BIN
      Apex Mobile/app/src/main/res/drawable-xhdpi/ic_launcher.png
  65. BIN
      Apex Mobile/app/src/main/res/drawable-xhdpi/ic_test.png
  66. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_about.png
  67. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_arrow.png
  68. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_cargo_tracking.png
  69. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_container_detail.png
  70. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_document.png
  71. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_down_doc.png
  72. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_exit.png
  73. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_file.png
  74. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_file128.png
  75. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_launcher.png
  76. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_launcher_new.png
  77. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_message.png
  78. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_message_new.png
  79. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_ocean_blinfo.png
  80. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_oceanbooking.png
  81. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_password.png
  82. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_pdf.png
  83. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_pdf128.png
  84. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_service_location.png
  85. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_test.png
  86. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_tools.png
  87. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/pop_bg9.9.png
  88. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_about.png
  89. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_announcements.png
  90. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_change_password.png
  91. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_history.png
  92. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_market_news.png
  93. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_search_documents.png
  94. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_search_history.png
  95. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_setting.png
  96. BIN
      Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_view_download_documents.png
  97. BIN
      Apex Mobile/app/src/main/res/drawable/apexlogo_2.png
  98. 14 0
      Apex Mobile/app/src/main/res/drawable/bg_button.xml
  99. 32 0
      Apex Mobile/app/src/main/res/drawable/bg_gardient.xml
  100. 16 0
      Apex Mobile/app/src/main/res/drawable/detail_item.xml

+ 19 - 0
Apex Mobile/Apex Mobile.iml

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

+ 188 - 0
Apex Mobile/app/app.iml

@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
+  <component name="FacetManager">
+    <facet type="android-gradle" name="Android-Gradle">
+      <configuration>
+        <option name="GRADLE_PROJECT_PATH" value=":app" />
+      </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$/src/main/res" />
+        <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
+      </configuration>
+    </facet>
+  </component>
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7">
+    <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
+    <output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/merged-not-compiled-resources" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/multi-dex" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard-rules" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res_stripped" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/tmp" />
+      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
+      <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
+      <excludeFolder url="file://$MODULE_DIR$/build/reports" />
+      <excludeFolder url="file://$MODULE_DIR$/build/tmp" />
+    </content>
+    <orderEntry type="jdk" jdkName="Android API 25 Platform" jdkType="Android SDK" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="com.android.support:multidex-1.0.2" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-tagmanager-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-appindexing-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-crash-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-drive-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-auth-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-awareness-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-tagmanager-v4-impl-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-wearable-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:support-core-ui-25.3.1" level="project" />
+    <orderEntry type="library" name="com.android.support:support-compat-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-iid-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-panorama-11.0.4" level="project" />
+    <orderEntry type="library" name="__local_aars__:/Users/ray/Documents/code_ERPSuiteAndroid/Apex Mobile/app/libs/baidumapapi_base_v3_7_1.jar:unspecified@jar" level="project" />
+    <orderEntry type="library" name="com.android.support:mediarouter-v7-25.2.0" level="project" />
+    <orderEntry type="library" name="com.android.support.constraint:constraint-layout-solver:1.0.2@jar" level="project" />
+    <orderEntry type="library" name="com.android.support:support-core-utils-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-iid-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-plus-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support.constraint:constraint-layout-1.0.2" level="project" />
+    <orderEntry type="library" name="com.android.support:support-v4-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-vision-common-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:support-media-compat-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-games-11.0.4" level="project" />
+    <orderEntry type="library" name="__local_aars__:/Users/ray/Documents/code_ERPSuiteAndroid/Apex Mobile/app/libs/baidumapapi_map_v3_7_1.jar:unspecified@jar" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-tasks-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-identity-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-vision-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-ads-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-ads-lite-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-cast-framework-11.0.4" level="project" />
+    <orderEntry type="library" scope="TEST" name="com.android.support:multidex-instrumentation-1.0.2" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-analytics-impl-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-common-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:palette-v7-25.2.0" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-analytics-impl-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:support-vector-drawable-25.3.1" level="project" />
+    <orderEntry type="library" name="com.android.support:recyclerview-v7-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-auth-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-base-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-places-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-config-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-auth-api-phone-11.0.4" level="project" />
+    <orderEntry type="library" name="__local_aars__:/Users/ray/Documents/code_ERPSuiteAndroid/Apex Mobile/app/libs/core-2.3.0.jar:unspecified@jar" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-database-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-analytics-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-storage-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-clearcut-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-nearby-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-storage-common-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-wallet-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-basement-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-cast-11.0.4" level="project" />
+    <orderEntry type="library" name="__local_aars__:/Users/ray/Documents/code_ERPSuiteAndroid/Apex Mobile/app/libs/httpmime-4.1.1.jar:unspecified@jar" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-appinvite-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:support-fragment-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-analytics-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-safetynet-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-dynamic-links-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:animated-vector-drawable-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-gcm-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-database-connection-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-instantapps-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-auth-base-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:appcompat-v7-25.3.1" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-maps-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.firebase:firebase-messaging-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-tagmanager-api-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-fitness-11.0.4" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-gass-11.0.4" level="project" />
+    <orderEntry type="library" name="com.android.support:support-annotations:25.3.1@jar" level="project" />
+    <orderEntry type="library" name="com.google.android.gms:play-services-location-11.0.4" level="project" />
+    <orderEntry type="library" name="org.apache.http.legacy-android-25" level="project" />
+  </component>
+</module>

+ 49 - 0
Apex Mobile/app/build.gradle

@@ -0,0 +1,49 @@
+apply plugin: 'com.android.application'
+
+android {
+    signingConfigs {
+        lbs_test {
+            keyAlias 'apex mobile'
+            keyPassword '#UL$dc01'
+            storeFile file('/Users/ray/Documents/usai android keystore/usai_keystore')
+            storePassword '#UL$dc01'
+        }
+    }
+    compileSdkVersion 25
+//    buildToolsVersion '25.0.3'
+    defaultConfig {
+        applicationId "com.usai.apex"
+        minSdkVersion 14
+        targetSdkVersion 25
+        multiDexEnabled true
+    }
+    buildTypes {
+        release {
+            minifyEnabled true
+            zipAlignEnabled true
+            shrinkResources true
+            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
+        }
+        debug {
+//            minifyEnabled true
+//            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
+            signingConfig signingConfigs.lbs_test
+        }
+    }
+}
+
+dependencies {
+    //    compile 'com.android.support:support-v4:19.1.0'
+    compile 'com.android.support:appcompat-v7:25.3.1'
+    compile 'com.android.support:support-v4:25.3.1'
+    compile 'com.android.support.constraint:constraint-layout:1.0.2'
+    compile 'com.android.support:recyclerview-v7:25.3.1'
+    compile 'com.google.android.gms:play-services:11.0.4'
+    compile files('libs/baidumapapi_base_v3_7_1.jar')
+    compile files('libs/baidumapapi_map_v3_7_1.jar')
+    compile files('libs/httpmime-4.1.1.jar')
+    compile files('libs/core-2.3.0.jar')
+}
+android {
+    useLibrary 'org.apache.http.legacy'
+}

BIN
Apex Mobile/app/libs/baidumapapi_base_v3_7_1.jar


BIN
Apex Mobile/app/libs/baidumapapi_map_v3_7_1.jar


BIN
Apex Mobile/app/libs/core-2.3.0.jar


BIN
Apex Mobile/app/libs/httpmime-4.1.1.jar


+ 21 - 0
Apex Mobile/app/lint.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<lint>
+    <issue id="ContentDescription" severity="ignore" />
+    <issue id="ExtraTranslation" severity="warning" />
+    <issue id="HardcodedDebugMode">
+        <ignore path="AndroidManifest.xml" />
+    </issue>
+    <issue id="HardcodedText">
+        <ignore path="res/layout/fragment_direct_tracking.xml" />
+    </issue>
+    <issue id="MissingTranslation" severity="warning" />
+    <issue id="TextFields">
+        <ignore path="res/layout/fragment_direct_tracking.xml" />
+    </issue>
+    <issue id="UselessParent">
+        <ignore path="res/layout/fragment_direct_tracking.xml" />
+    </issue>
+    <issue id="ValidFragment">
+        <ignore path="src/com/usai/apex/DetailFragment.java" />
+    </issue>
+</lint>

+ 40 - 0
Apex Mobile/app/proguard-project.txt

@@ -0,0 +1,40 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
+#-libraryjars   /libs/android-support-v4.jar
+#-libraryjars   /libs/httpmime-4.1.1.jar
+
+-dontwarn android.support.v4.** 
+-dontwarn com.google.android.gms.** 
+
+
+# Remove all Verbose/Debug logging
+-optimizations code/removal/simple,code/removal/advanced
+-dontobfuscate
+-assumenosideeffects class android.util.Log {
+    public static *** d(...);
+    public static *** v(...);
+    public static *** i(...);
+}
+
+
+-keep class com.baidu.** {*;}
+#-keep class com.baidu.mapapi.** {*;}
+-keep class vi.com.gdi.bgl.** {*;}

+ 309 - 0
Apex Mobile/app/src/main/AndroidManifest.xml

@@ -0,0 +1,309 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.usai.apex"
+    android:versionCode="7"
+    android:versionName="A160422" >
+
+    <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
+    <uses-sdk
+        android:minSdkVersion="14"
+        android:targetSdkVersion="18" />
+
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+    <!--
+         <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
+    <uses-permission android:name="com.android.launcher.permission.UNINSTALL_SHORTCUT" />
+    -->
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.READ_CONTACTS" />
+    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
+    <!-- External storage for caching. -->
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <!-- My Location -->
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
+    <!-- Maps API needs OpenGL ES 2.0. -->
+    <uses-feature
+        android:glEsVersion="0x00020000"
+        android:required="true" />
+    <!-- End of copy. -->
+
+
+    <!-- Baidu Map API -->
+
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+
+    <!--
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+
+    <permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
+    </permission>
+
+    <uses-permission android:name="android.permission.BAIDU_LOCATION_SERVICE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.INTERNET" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" >
+    </uses-permission>
+    -->
+    <!-- <uses-permission android:name="android.permission.WRITE_APN_SETTINGS"></uses-permission> -->
+    <!--
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
+    </uses-permission>
+    <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
+   
+    <uses-permission android:name="android.permission.ACCESS_GPS" />
+    -->
+
+
+    <!--
+    <uses-permission android:name="android.permission.CALL_PHONE" />
+    <uses-permission android:name="android.permission.READ_SMS" />
+    <uses-permission android:name="android.permission.SEND_SMS" />
+    -->
+    <!-- SDK1.5需要android.permission.GET_TASKS权限判断本程序是否为当前运行的应用? -->
+    <!--
+        <uses-permission android:name="android.permission.GET_TASKS" />
+     <uses-permission android:name="android.permission.CAMERA" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.RECORD_AUDIO" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
+    <uses-permission android:name="android.permission.BROADCAST_STICKY" />
+    -->
+
+
+    <!-- 来电消音 -->
+    <!--
+    <uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
+    -->
+    <application
+        android:name="com.usai.apex.ApexTrackingApplication"
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@android:style/Theme.Holo.Light" >
+
+        <!-- release key -->
+       <meta-data
+            android:name="com.google.android.maps.v2.API_KEY"
+            android:value="AIzaSyDdbk58Lx6QzaXcB_hNpSHVp3l_CJeNpoo" />
+
+           <meta-data
+        android:name="com.baidu.lbsapi.API_KEY"
+        android:value="nqBQoSDbxrslhuzW91uViQX7" />
+      
+        <!-- debug key -->
+
+
+        
+<!--                   <meta-data
+            android:name="com.google.android.maps.v2.API_KEY"
+            android:value="AIzaSyARPN7VaYqWGe1PsgGqp1QlhOoTdiwTqq0" />
+
+  <meta-data
+        android:name="com.baidu.lbsapi.API_KEY"
+        android:value="tznWFxd3RvSoul1TGQp6GSzo" />  -->
+        
+  
+        <meta-data
+            android:name="com.google.android.gms.version"
+            android:value="@integer/google_play_services_version" />
+
+        <activity
+            android:name="com.usai.apex.DetailActivity"
+            android:label="@string/title_activity_detail"
+            android:screenOrientation="landscape" >
+
+            <!--
+                 <meta-data
+                android:name="android.support.PARENT_ACTIVITY"
+                android:value="android.support.v4.app.FragmentActivity" />
+
+           
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+
+            -->
+        </activity>
+        <activity
+            android:name="com.usai.apex.ApexActivity"
+            android:label="@string/title_activity_apex"
+            android:logo="@drawable/apexlogo_2"
+            android:screenOrientation="portrait"
+            android:windowSoftInputMode="adjustPan" >
+        </activity>
+        <!--
+             <activity
+            android:name="com.usai.apex.LoginFragment"
+            android:label="@string/title_activity_login"
+            android:windowSoftInputMode="adjustResize|stateVisible" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.DirectTrackingFragment"
+            android:label="@string/title_activity_direct_tracking" >
+        </activity>
+
+
+
+
+
+
+        -->
+        <activity
+            android:name="com.usai.apex.FunctionSelectActivity"
+            android:label="@string/title_activity_function_select"
+            android:launchMode="singleTop"
+            android:logo="@drawable/apexlogo_2"
+            android:screenOrientation="portrait" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:name="com.usai.apex.SearchActivity"
+            android:label="@string/title_activity_search"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.AnnouncementActivity"
+            android:label="@string/title_activity_announcements"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.CustomizeFieldsActivity"
+            android:label="@string/title_activity_customize_fields"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.ResultActivity"
+            android:label="@string/title_activity_result" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.LocationDetailActivity"
+            android:label="@string/title_activity_location_detail" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.InnerMapActivity"
+            android:label="@string/title_activity_inner_map" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.HelpActivity"
+            android:label="@string/title_activity_help"
+            android:screenOrientation="portrait"
+            android:theme="@android:style/Theme.Holo.NoActionBar" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.SearchListActivity"
+            android:label="@string/title_activity_search_list"
+            android:screenOrientation="portrait"
+            android:windowSoftInputMode="adjustUnspecified|stateHidden" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.RetrievePasswordActivity"
+            android:label="@string/title_activity_retrieve_password"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.MessageActivity"
+            android:label="@string/title_activity_message"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.SearchHistoryActivity"
+            android:label="@string/title_activity_search_history"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.ChangePasswordActivity"
+            android:label="Change Password"
+            android:screenOrientation="portrait"
+            android:windowSoftInputMode="adjustResize|stateVisible" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.AboutActivity"
+            android:label="@string/title_activity_about"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.WebActivity"
+            android:label="@string/title_activity_web" >
+        </activity>
+
+        <receiver
+            android:name="com.usai.apex.BootBroadcastReceiver"
+            android:permission="android.permission.RECEIVE_BOOT_COMPLETED" >
+            <intent-filter>
+                <action android:name="android.intent.action.BOOT_COMPLETED" />
+                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
+                
+            </intent-filter>
+        </receiver>
+        <receiver android:name="com.usai.apex.Alarmreceiver" >
+            <intent-filter>
+                <action android:name="com.usai.apex.push" />
+                <action android:name="com.usai.apex.push.cancel" />
+            </intent-filter>
+        </receiver>
+
+        <activity
+            android:name="com.usai.apex.MessageDetailActivity"
+            android:label="@string/title_activity_message_detail"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.InnerToolsActivity"
+            android:label="@string/title_activity_inner_tools"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.DocumentsActivity"
+            android:label="@string/title_activity_documents"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.LocalDocumentActivity"
+            android:label="@string/title_activity_localdocuments"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.ApexHistoryActivity"
+            android:label="@string/title_activity_apexhistory"
+            android:screenOrientation="portrait" >
+        </activity>
+        <activity
+            android:name="com.usai.apex.SettingsActivity"
+            android:label="@string/title_activity_settings"
+            android:screenOrientation="portrait"  >
+        </activity>
+                <service
+            android:name="com.usai.apex.ApexBackgroundService"
+            android:label="Apex Mobile Background Service" >
+        </service>
+    </application>
+
+</manifest>

+ 72 - 0
Apex Mobile/app/src/main/java/com/usai/apex/AboutActivity.java

@@ -0,0 +1,72 @@
+package com.usai.apex;
+
+import java.io.InputStream;
+
+import org.apache.http.util.EncodingUtils;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.util.Log;
+import android.webkit.WebView;
+import android.widget.TextView;
+
+public class AboutActivity extends Activity
+{
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		Log.d("AboutActivity", "onCreate");
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_about);
+		final TextView tv_ver = (TextView) findViewById(R.id.tv_version);
+
+		// String str =
+		// "<a href='https://ra.apexshipping.com/main.php?action=handset_search&action_type=download_doc&sessionid=hjqvgilu0o64d22qfqgat1afk2&url=QVRwVUswa3ZFNlBFTzhLbFpYcC9rVEhSZ1h0MGd6ekpwZ2ZqTkhXNnN2SytGM0FhRkhyNG5QbkdtV2tPMXZrK2p3' target=_blank>A1303540085F.pdf</a>";
+
+//		WebView wv = (WebView) findViewById(R.id.webView1);
+//		String content = "";
+//		try
+//		{
+//			InputStream in = getResources().openRawResource(R.raw.about);
+//			// 获取文件的字节数
+//			int lenght = in.available();
+//			// 创建byte数组
+//			byte[] buffer = new byte[lenght];
+//			// 将文件中的数据读到byte数组中
+//			in.read(buffer);
+//			content = EncodingUtils.getString(buffer, "UTF-8");
+//		}
+//		catch (Exception e)
+//		{
+//			e.printStackTrace();
+//		}
+//		wv.getSettings().setDefaultTextEncodingName("UTF-8");
+//		wv.loadData(content, "text/html", null);
+//		
+		
+		try
+		{
+			
+			tv_ver.setText(getText(R.string.str_ver)
+					+ ApexTrackingApplication.get_instance()
+							.getPackageManager()
+							.getPackageInfo("com.usai.apex", 0).versionName);
+		}
+		catch (NameNotFoundException e1)
+		{
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+	}
+	//
+	// @Override
+	// public boolean onCreateOptionsMenu(Menu menu) {
+	// // Inflate the menu; this adds items to the action bar if it is present.
+	// getMenuInflater().inflate(R.menu.about, menu);
+	// return true;
+	// }
+
+}

+ 362 - 0
Apex Mobile/app/src/main/java/com/usai/apex/Alarmreceiver.java

@@ -0,0 +1,362 @@
+package com.usai.apex;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.util.Crypto;
+import com.usai.util.Network;
+import com.usai.util.dbUtil;
+import com.usai.util.dbgUtil;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.AsyncTask;
+import android.os.Parcelable;
+import android.os.SystemClock;
+import android.util.Log;
+
+public class Alarmreceiver extends BroadcastReceiver
+{
+	private SearchTask	m_task	= null;
+
+	public void checkpush(Context context)
+	{
+
+		if (m_task != null)
+		{
+			return;
+		}
+		// mStatusMessageView.setText(R.string.str_Loading);
+		// showProgress(true);
+		m_task = new SearchTask(context);
+
+		// TextView text_page = (TextView) view_page_footer
+		// .findViewById(R.id.text_page);
+		// text_page.setText("Loading...");
+		// text_page.setEnabled(false);
+		m_task.execute();
+
+	}
+
+	class SearchTask extends AsyncTask<Void, Void, Boolean>
+	{
+		int		errorcode;
+		String	content	= null;
+		Context	mcontext;
+
+		public SearchTask(Context context)
+		{
+			mcontext = context;
+		}
+
+		@Override
+		protected Boolean doInBackground(Void... params)
+		{
+			Log.d("SearchTask", "doInBackground");
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+			String jstr = "";
+			jstr = Network.check_push();
+			// if (module_name.equals("Announcements"))
+			// jstr = Network.get_announcements(lastid, limit);
+			// else
+			// jstr = Network.get_marketnews(lastid, limit);
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			content = jstr;
+			return true;
+		}
+
+		@Override
+		protected void onPostExecute(Boolean success)
+		{
+			String tag = "onPostExec@Alarmreceiver";
+			Log.i( tag, "entry");
+			m_task = null;
+			// showProgress(false);
+
+			// switch (errorcode)
+			// {
+			// // case Network.RESULT_NET_NOTAVAILABLE:
+			// // {
+			// // Toast toast = Toast.makeText(
+			// // ApexTrackingApplication.get_instance(),
+			// // getText(R.string.msg_connection_none),
+			// // Toast.LENGTH_LONG);
+			// // toast.setGravity(Gravity.CENTER, 0, 0);
+			// // toast.show();
+			// // break;
+			// // }
+			// // case Network.RESULT_NET_ERROR:
+			// // {
+			// // Toast toast = Toast.makeText(
+			// // ApexTrackingApplication.get_instance(),
+			// // getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+			// // toast.setGravity(Gravity.CENTER, 0, 0);
+			// // toast.show();
+			// // break;
+			// // }
+			// // case Network.RESULT_ERROR:
+			// // // case Network.RESULT_RESPONSE_NULL:
+			// // {
+			// // Toast toast = Toast.makeText(
+			// // ApexTrackingApplication.get_instance(),
+			// // getText(R.string.msg_net_resulterror),
+			// // Toast.LENGTH_LONG);
+			// // toast.setGravity(Gravity.CENTER, 0, 0);
+			// // toast.show();
+			// // break;
+			// // }
+			//
+			// default:
+			// break;
+			// }
+
+			if (success)
+			{
+				JSONObject jsobj;
+				//
+				// array = new JSONArray(json);
+				try
+				{
+					jsobj = new JSONObject(content);
+
+					String message = jsobj.getString("message");
+					String date = jsobj.getString("date");
+					String s_id = jsobj.getString("s_id");
+					String e_id = jsobj.getString("e_id");
+					int count = jsobj.getInt("count");
+					SQLiteDatabase db = dbUtil.OpenDB(
+							ApexTrackingApplication.get_instance(), null, true);
+					db.execSQL("insert into push_message(s_id,e_id,msgcount,message,h_time,user,create_time,read) values('"
+							+ s_id
+							+ "','"
+							+ e_id
+							+ "',"
+							+ count
+							+ ",'"
+							+ message
+							+ "','"
+							+ date
+							+ "','"
+							+ ApexTrackingApplication.get_user()
+							+ "',"
+							+ System.currentTimeMillis() + ",0)");
+					dbUtil.CloseDB(db);
+
+					boolean bnotify = mcontext.getSharedPreferences("setting",
+							0).getBoolean("notifications_new_message", true);
+					if (bnotify)
+					{
+
+						boolean bsound = mcontext.getSharedPreferences(
+								"setting", 0).getBoolean(
+								"notifications_new_message_sound", true);
+						boolean bvibrate = mcontext.getSharedPreferences(
+								"setting", 0).getBoolean(
+								"notifications_new_message_vibrate", true);
+						NotificationManager nManager = (NotificationManager) mcontext
+								.getSystemService(Context.NOTIFICATION_SERVICE);
+
+//						Notification notification = new Notification(
+//								R.drawable.ic_launcher,
+//								mcontext.getString(R.string.str_notification_title),
+//								System.currentTimeMillis());
+						Intent intent = new Intent(mcontext,
+								FunctionSelectActivity.class);
+						intent.putExtra("launcher", "notification");
+
+						PendingIntent pintent = PendingIntent.getActivity(
+								mcontext, 0, intent,
+								PendingIntent.FLAG_UPDATE_CURRENT);
+
+
+						Notification.Builder builder = new Notification.Builder(mcontext);//新建Notification.Builder对象
+						String ntitle = "";
+						int number = ApexTrackingApplication.ncount++;
+						if (number > 1)
+							ntitle=number
+									+ " "
+									+ ApexTrackingApplication
+									.get_instance()
+									.getString(
+											R.string.str_mnotification_title);
+						else
+							ntitle = ApexTrackingApplication
+									.get_instance()
+									.getString(
+											R.string.str_notification_title);
+
+						builder.setContentTitle(ntitle);//设置标题
+						builder.setContentText(ApexTrackingApplication
+								.get_instance()
+								.getString(
+										R.string.str_notification_text)
+								+ date);//设置内容
+						builder.setSmallIcon(R.drawable.ic_launcher);//设置图片
+						builder.setContentIntent(pintent);//执行intent
+						Notification notification = builder.getNotification();//将builder对象转换为普通的notifications
+
+						if (bsound && bvibrate)
+							notification.defaults = Notification.DEFAULT_ALL;
+						else if (bsound)
+							notification.defaults = Notification.DEFAULT_SOUND
+									| Notification.DEFAULT_LIGHTS;
+						else if (bvibrate)
+							notification.defaults = Notification.DEFAULT_VIBRATE
+									| Notification.DEFAULT_LIGHTS;
+						notification.flags = Notification.FLAG_AUTO_CANCEL;
+						notification.number = number;
+//						if (notification.number > 1)
+//							notification
+//									.setLatestEventInfo(
+//											mcontext,
+//											notification.number
+//													+ " "
+//													+ ApexTrackingApplication
+//															.get_instance()
+//															.getString(
+//																	R.string.str_mnotification_title),
+//											ApexTrackingApplication
+//													.get_instance()
+//													.getString(
+//															R.string.str_notification_text)
+//													+ date, pintent);
+//						else
+//							notification
+//									.setLatestEventInfo(
+//											mcontext,
+//
+//											ApexTrackingApplication
+//													.get_instance()
+//													.getString(
+//															R.string.str_notification_text)
+//													+ date, pintent);
+						nManager.notify(R.layout.activity_apex, notification);
+					}
+
+					// Intent intenticon = new Intent();
+					// intenticon.setClass(ApexTrackingApplication
+					// .get_instance(), FunctionSelectActivity.class);
+					// Intent addShortcut = new
+					// Intent("com.android.launcher.action.INSTALL_SHORTCUT");
+					// Parcelable icon =
+					// Intent.ShortcutIconResource.fromContext(mcontext,
+					// R.drawable.ic_launcher_new);
+					// addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
+					// ApexTrackingApplication
+					// .get_instance().getString(R.string.app_name));
+					// addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT,
+					// intent);
+					// addShortcut.putExtra("duplicate", 0);
+					// addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
+					// icon);
+					// ApexTrackingApplication
+					// .get_instance().sendBroadcast(addShortcut);
+
+					// notification
+
+				}
+				catch (JSONException e)
+				{
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+				// if (bfinish)
+				// {
+				// // getListView().removeFooterView(view_page_footer);
+				// // Toast.makeText(AnnouncementActivity.this, "Load all!",
+				// // Toast.LENGTH_LONG).show();
+				//
+				// TextView tv = (TextView) view_page_footer
+				// .findViewById(R.id.text_page);
+				// tv.setText("No more items");
+				// tv.setEnabled(false);
+				// }
+				// else
+				// {
+				// TextView tv = (TextView) view_page_footer
+				// .findViewById(R.id.text_page);
+				// tv.setText("More...");
+				// tv.setEnabled(true);
+				// }
+				// adapter.notifyDataSetChanged();
+				// // getListAdapter().notifyDataSetChanged;
+				// // BaseAdapter mJson = null;
+				// // mJson.notifyDataSetChanged();
+			}
+
+			super.onPostExecute(success);
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			m_task = null;
+			// showProgress(false);
+		}
+	}
+
+	@Override
+	public void onReceive(Context context, Intent intent)
+	{
+		String tag = "onReceive@Alarmreceiver";
+		if (intent.getAction().equals("com.usai.apex.push"))
+		{
+
+			// Bundle b = intent.getExtras();
+			// Set<String> keySet = b.keySet();
+			// for(String key : keySet) {
+			// Log.e(tag, key);
+			// }
+			// String s =b.getString("caller");
+			Log.i( tag, "receive alarm broadcast caller =="
+					+ intent.getStringExtra("caller"));
+
+			if (SystemClock.elapsedRealtime()
+					- ApexTrackingApplication.getLastCheckMessageTime() > 120000)
+			{
+				Log.i(tag, "check messsage");
+				ApexTrackingApplication.UpdateLastCheckMessageTime();
+				checkpush(context);
+
+			}
+			// Intent i = new Intent();
+			// i.setClass(context, DaemonService.class);
+			// // 启动service
+			// // 多次调用startService并不会启动多个service 而是会多次调用onStart
+			// context.startService(i);
+		}
+		else if (intent.getAction().equals("com.usai.apex.push.cancel"))
+		{
+			if (m_task != null)
+				m_task.cancel(true);
+			NotificationManager nManager = (NotificationManager) context
+					.getSystemService(Context.NOTIFICATION_SERVICE);
+			nManager.cancel(R.layout.activity_apex);
+			ApexTrackingApplication.cancelalarm();
+			// ApexTrackingApplication.put_password("");
+			// ApexTrackingApplication.put_sessionid("");
+			// ApexTrackingApplication.put_user("");
+			ApexTrackingApplication.logout();
+
+		}
+	}
+
+}

+ 424 - 0
Apex Mobile/app/src/main/java/com/usai/apex/AnnouncementActivity.java

@@ -0,0 +1,424 @@
+package com.usai.apex;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.apex.ResultActivity.SearchTask;
+import com.usai.util.Network;
+import android.app.ListActivity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Base64;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class AnnouncementActivity extends ListActivity
+{
+	String				lastid			= "";
+	int					limit			= 10;
+	private SearchTask	m_task			= null;
+	SearchResult		searchresult	= new SearchResult();
+	BaseAdapter			adapter			= null;
+	View				view_page_footer;
+
+	String				module_name		= "";
+
+	public void requestdata()
+	{
+
+		if (m_task != null)
+		{
+			return;
+		}
+		// mStatusMessageView.setText(R.string.str_Loading);
+		// showProgress(true);
+		m_task = new SearchTask();
+
+		TextView text_page = (TextView) view_page_footer
+				.findViewById(R.id.text_page);
+		text_page.setText("Loading...");
+		text_page.setEnabled(false);
+		m_task.execute();
+
+	}
+
+	@Override
+	protected void onListItemClick(ListView l, View v, int position, long id)
+	{
+		// TODO Auto-generated method stub
+		super.onListItemClick(l, v, position, id);
+
+		// Log.i("FragmentList", "Item clicked: " + id);
+		Intent intent = new Intent();
+		intent.putExtra("url", searchresult.getData().get(position).get("url")
+				.toString());
+		intent.putExtra("title", searchresult.getData().get(position).get("title")
+				.toString());
+		intent.setClass(this, WebActivity.class);
+		startActivity(intent);
+	}
+
+	@Override
+	public void onDestroy()
+	{
+		if (m_task != null)
+			m_task.cancel(false);
+		super.onDestroy();
+	}
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+
+		// setTitle("Booking Result");
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_announcements);
+		adapter = new AnnouncementAdapter(searchresult, this);
+
+		module_name = getIntent().getStringExtra("module_name");
+
+		setTitle(module_name);
+		view_page_footer = LayoutInflater.from(this).inflate(
+				R.layout.view_page_footer, null);
+		getListView().addFooterView(view_page_footer);// 添加底部视图
+		TextView text_page = (TextView) view_page_footer
+				.findViewById(R.id.text_page);
+		text_page.setOnClickListener(new View.OnClickListener()
+		{
+			// 点击按钮 追加数据 并通知适配器
+			@Override
+			public void onClick(View v)
+			{
+				// TODO Auto-generated method stub
+				// TextView tv = (TextView) v;
+				// tv.setText("Loading...");
+				requestdata();
+				// tv.setText("下一页");
+				// adapter.notifyDataSetChanged();
+			}
+		});
+
+		setListAdapter(adapter);
+		// this.getListView().setBackgroundColor(Color.WHITE);
+		requestdata();
+
+	}
+
+	class SearchTask extends AsyncTask<Void, Void, Boolean>
+	{
+		int		errorcode;
+		boolean	bfinish	= false;
+
+		@Override
+		protected Boolean doInBackground(Void... params)
+		{
+			Log.d("SearchTask", "doInBackground");
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+			String jstr;
+			if (module_name.equals("Announcements"))
+				jstr = Network.get_announcements(lastid, limit);
+			else
+				jstr = Network.get_marketnews(lastid, limit);
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			JSONObject jsobj;
+			//
+			// array = new JSONArray(json);
+			try
+			{
+				jsobj = new JSONObject(jstr);
+				// if (searchresult.get_fieldscount() == 0)
+				// {
+				// JSONObject objfields = jsobj.getJSONObject("fields");
+				// if (objfields != null)
+				// searchresult.init_fields(objfields.toString());
+				// }
+				int count = jsobj.getInt("total");
+				if (count < limit)
+					bfinish = true;
+				JSONObject objrecords = jsobj.getJSONObject("records");
+				if (objrecords != null)
+					searchresult.add_records(objrecords.toString(), count);
+				errorcode = Network.RESULT_TRUE;
+
+				return true;
+
+			}
+			catch (JSONException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			errorcode = Network.RESULT_NET_ERROR;
+			return false;
+		}
+
+		@Override
+		protected void onPostExecute(Boolean success)
+		{
+			String tag = "onPostExecute@AnnouncementActivity";
+			Log.d("onPostExecute", "entry");
+			m_task = null;
+			// showProgress(false);
+
+			switch (errorcode)
+			{
+				case Network.RESULT_NET_NOTAVAILABLE:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_NET_ERROR:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_resulterror),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+
+				default:
+					break;
+			}
+
+			if (success)
+			{
+
+				if (bfinish)
+				{
+					// getListView().removeFooterView(view_page_footer);
+					// Toast.makeText(AnnouncementActivity.this, "Load all!",
+					// Toast.LENGTH_LONG).show();
+
+					TextView tv = (TextView) view_page_footer
+							.findViewById(R.id.text_page);
+					tv.setText("No more items");
+					tv.setEnabled(false);
+				}
+				else
+				{
+					TextView tv = (TextView) view_page_footer
+							.findViewById(R.id.text_page);
+					tv.setText("More...");
+					tv.setEnabled(true);
+				}
+				adapter.notifyDataSetChanged();
+				// getListAdapter().notifyDataSetChanged;
+				// BaseAdapter mJson = null;
+				// mJson.notifyDataSetChanged();
+			}
+			else
+			{
+				TextView tv = (TextView) view_page_footer
+						.findViewById(R.id.text_page);
+				tv.setText("More...");
+				tv.setEnabled(true);
+			}
+			super.onPostExecute(success);
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			m_task = null;
+			// showProgress(false);
+		}
+	}
+
+	private class SearchResult
+	{
+		List<Map<String, Object>>	datalist	= new ArrayList<Map<String, Object>>();
+
+		public int get_count()
+		{
+			return datalist.size();
+		}
+
+		public void add_records(String source, int count)
+		{
+			JSONObject objrecords;
+			try
+			{
+				objrecords = new JSONObject(source);
+
+				for (int i = 0; i < count; i++)
+				{
+					// offset++;
+					JSONObject objrec = objrecords.getJSONObject("record" + i);
+					String title = objrec.getString("title");
+					String content = objrec.getString("content");
+					String image = objrec.getString("image");
+					String id = objrec.getString("id");
+					String url = objrec.getString("url");
+					lastid = id;
+					Map<String, Object> map = new HashMap<String, Object>();
+					map.put("title", title);
+					map.put("content", content);
+					map.put("image", image);
+					map.put("id", id);
+					map.put("url", url);
+					datalist.add(map);
+
+					// Iterator<?> it = rec.keys();
+					// HashMap<String, String> record = new HashMap<String,
+					// String>();
+					// while (it.hasNext()) // loop for each function
+					// {
+					// String field_name = (String) it.next();
+					// String val = rec.getString(field_name)
+					// .replace("\n", "");
+					// record.put(field_name, val);
+					// }
+					// records.add(record);
+
+				}
+			}
+			catch (JSONException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+
+		}
+
+		public List<Map<String, Object>> getData()
+		{
+
+			return datalist;
+		}
+	}
+
+	private class AnnouncementAdapter extends BaseAdapter
+	{
+		private LayoutInflater	mInflater;	// 动态布局映射
+		private SearchResult	result;
+
+		// private Context context;
+		// private int i = 0;
+		public AnnouncementAdapter(SearchResult result, Context context)
+		{
+			this.result = result;
+			// this.context = context;
+			this.mInflater = LayoutInflater.from(context);
+		}
+
+		@Override
+		public int getCount()
+		{
+			// TODO Auto-generated method stub
+			return result.get_count();
+		}
+
+		@Override
+		public Object getItem(int position)
+		{
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		@Override
+		public long getItemId(int position)
+		{
+			// TODO Auto-generated method stub
+			return 0;
+		}
+
+		@Override
+		public View getView(int position, View convertView, ViewGroup parent)
+		{
+			// TODO Auto-generated method stub
+			convertView = mInflater.inflate(R.layout.announcement_item, null);// 根据布局文件实例化view
+
+			TextView title = (TextView) convertView.findViewById(R.id.tv_title);// 找某个控件
+			title.setText(result.getData().get(position).get("title")
+					.toString());// 给该控件设置数据(数据从集合类中来)
+			TextView content = (TextView) convertView
+					.findViewById(R.id.tv_content);
+			content.setText(result.getData().get(position).get("content")
+					.toString());
+			if (result.getData().get(position).get("image").toString().length() > 0)
+			{
+				byte[] gzipBuff = Base64.decode(result.getData().get(position)
+						.get("image").toString(), 0);
+
+				ByteArrayInputStream memstream = new ByteArrayInputStream(
+						gzipBuff, 0, gzipBuff.length);
+
+				ByteArrayOutputStream baos = new ByteArrayOutputStream(
+						gzipBuff.length);
+				ImageView iv_thumb = (ImageView) convertView
+						.findViewById(R.id.iv_thumb);
+				try
+				{
+					baos.write(gzipBuff);
+
+					Bitmap bmp = BitmapFactory.decodeStream(memstream);
+
+					// ImageView image = new ImageView(this);
+
+					iv_thumb.setImageBitmap(bmp);
+				}
+				catch (IOException e)
+				{
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+			// img.setBackgroundResource((Integer)jObject.get("img"));
+
+			return convertView;
+		}
+	}
+}

+ 217 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ApexActivity.java

@@ -0,0 +1,217 @@
+package com.usai.apex;
+
+//import com.google.android.gms.maps.SupportMapFragment;
+
+import android.app.ActionBar;
+import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Bundle;
+//import android.app.Fragment;
+//import android.app.FragmentTransaction;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.widget.TabHost;
+
+public class ApexActivity extends FragmentActivity /*
+													 * implements
+													 * OnTabChangeListener
+													 */
+{
+	boolean	m_bhasgoogleframework	= false;
+
+	@Override
+	public boolean onKeyDown(int keyCode, KeyEvent event)
+	{
+		if (keyCode == KeyEvent.KEYCODE_BACK)
+		{
+			// Intent myIntent = new Intent();
+			// myIntent = new Intent(EditActivity.this, tabActivity.class);
+			// startActivity(myIntent);
+			finish();
+			
+			return false;
+		}
+		return super.onKeyDown(keyCode, event);
+	}
+
+	TabHost	mTabHost;
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		Log.d("ApexActivity", "onCreate");
+
+		// ApexTrackingApplication.get_instance()
+		// .getPackageManager().
+		PackageInfo packageInfo;
+		try
+		{
+			packageInfo = this.getPackageManager().getPackageInfo(
+					"com.google.android.gms", 0);
+
+		}
+		catch (NameNotFoundException e)
+		{
+			packageInfo = null;
+			e.printStackTrace();
+		}
+		if (packageInfo == null)
+		{
+			m_bhasgoogleframework = false;
+			System.out.println("没有安装");
+		}
+		else
+		{
+			m_bhasgoogleframework = true;
+			System.out.println("已经安装");
+		}
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_apex);
+		ActionBar bar = getActionBar();
+		bar.setTitle("");
+		setupTabs();
+
+	}
+
+	// @Override
+	// public boolean onCreateOptionsMenu(Menu menu) {
+	// // Inflate the menu; this adds items to the action bar if it is present.
+	// getMenuInflater().inflate(R.menu.apex, menu);
+	// return true;
+	// }
+	//
+	// @Override
+	// public boolean onOptionsItemSelected(MenuItem item) {
+	// switch (item.getItemId()) {
+	// case R.id.forget_password:
+	// Intent intent = new Intent();
+	// intent.setClass(this, RetrievePasswordActivity.class);
+	// startActivity(intent);
+	//
+	// break;
+	// default:
+	// break;
+	//
+	// }
+	// return super.onOptionsItemSelected(item);
+	// }
+
+	private void setupTabs()
+	{
+		mTabHost = (TabHost) this.findViewById(R.id.tabhost);
+
+		mTabHost.setup();
+		// // ��ɵײ��Զ�����ʽ�İ�ť
+		// String[] title = new String[] { "Login", "Not login" };
+		// int[] tabIds = new int[] { R.id.tab1, R.id.tab2 };
+		mTabHost.addTab(mTabHost.newTabSpec(getString(R.string.action_sign_in_short)).setIndicator(getString(R.string.action_sign_in_short))
+				.setContent(R.id.tab1));
+		// mTabHost.addTab(mTabHost.newTabSpec("test").setIndicator("test").setContent(R.id.tabtest));
+
+		mTabHost.addTab(mTabHost.newTabSpec(getString(R.string.str_tool)).setIndicator(getString(R.string.str_tool))
+				.setContent(R.id.tab2));
+		mTabHost.addTab(mTabHost.newTabSpec(getString(R.string.str_location))
+				.setIndicator(getString(R.string.str_location)).setContent(R.id.tab3));
+
+		// Instantiate a new fragment.
+		Fragment loginFragment = new LoginFragment();
+		Fragment toolsFragment = new ToolsFragment();
+		Fragment slFragment;
+//		 m_bhasgoogleframework=false;
+		if (m_bhasgoogleframework)
+			slFragment = new ServiceLocationFragment();
+		else
+			slFragment = new BaiduMapFragment();
+		// Add the fragment to the activity, pushing this transaction
+		// on to the back stack.
+
+		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+		ft.replace(R.id.tab1, loginFragment);
+		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		ft.addToBackStack("Login");
+
+		ft.replace(R.id.tab2, toolsFragment);
+		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		ft.addToBackStack("Tools");		
+		
+		
+		// ft.replace(R.id.tab2, dtFragement);
+		// ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		// ft.addToBackStack("Tracking");
+		// Fragment test = new ServiceLocationFragment();
+		// ft.replace(R.id.tabtest, (Fragment) test);
+		// ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		// ft.addToBackStack("test");
+
+		ft.replace(R.id.tab3, (Fragment) slFragment);
+		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		ft.addToBackStack("Location");
+
+		ft.commit();
+
+		// if (manager.findFragmentByTag(tabId) == null)
+		// {
+		// FragmentTransaction trans = manager.beginTransaction();
+		// trans.replace(contentViewID, frag, tabId);
+		// trans.commit();
+		// }
+		// for (int i = 0; i < title.length; i++) {
+		// Button button = new Button(this);
+		// button.setText(title[i]);
+		// button.setBackgroundDrawable(this.getResources().getDrawable(
+		// R.drawable.tab_lable)); //�Զ��尴ť��ʽ
+		// mTabHost.addTab(mTabHost.newTabSpec(title[i]).setIndicator(button)
+		// .setContent(tabIds[i]));
+		// }
+
+		// mTabHost.setOnTabChangedListener(this);
+	}
+
+	// @Override
+	// public void onTabChanged(String tabId)
+	// {
+	// TODO Auto-generated method stub
+	// Fragment frag = null;
+	// int contentViewID = 0;
+	// if (tabId.equals("Login")) {
+	// frag = new LoginFragment();
+	// //�Զ���̳�Fragment��UI������һ���򵥵���ʾ�ı�����Ŀؼ���
+	// contentViewID = R.id.tab1;
+	// } else if (tabId.equals("Not login")) {
+	// frag = new DirectTrackingFragment();
+	// contentViewID = R.id.tab2;
+	// }
+	// if (frag == null)
+	// return;
+	//
+	// FragmentManager manager = this.getFragmentManager();
+	//
+	// if (manager.findFragmentByTag(tabId) == null) {
+	// FragmentTransaction trans = manager.beginTransaction();
+	// trans.replace(contentViewID, frag, tabId);
+	// trans.commit();
+	// }
+	// }
+	// public class LoginFragment extends Fragment implements OnClickListener{
+	// @Override
+	// public View onCreateView(LayoutInflater inflater, ViewGroup container,
+	// Bundle savedInstanceState) {
+	// View view = inflater.inflate(R.layout.activity_login, null);
+	// Button btn = (Button)view.findViewById(R.id.sign_in_button);
+	// btn.setOnClickListener(this);
+	// return view;
+	// }
+	//
+	// @Override
+	// public void onClick(View v)
+	// {
+	// // TODO Auto-generated method stub
+	//
+	// }
+	// }
+}

+ 51 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ApexBackgroundService.java

@@ -0,0 +1,51 @@
+package com.usai.apex;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.util.Log;
+
+public class ApexBackgroundService extends Service
+{
+
+	ApexTrackingApplication app = null;
+	
+	
+	
+	@Override
+	public void onCreate()
+	{
+		app = ApexTrackingApplication.get_instance();
+
+		super.onCreate();
+	}
+
+
+
+	@Override
+	public void onStart(Intent intent, int startId)
+	{
+		if(app==null)
+			Log.e("service start","app is null");
+		super.onStart(intent, startId);
+	}
+
+
+
+	@Override
+	public int onStartCommand(Intent intent, int flags, int startId)
+	{
+
+		return super.onStartCommand(intent, flags, startId);
+	}
+
+
+
+	@Override
+	public IBinder onBind(Intent intent)
+	{
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

+ 43 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ApexHistoryActivity.java

@@ -0,0 +1,43 @@
+package com.usai.apex;
+
+import java.io.InputStream;
+
+import org.apache.http.util.EncodingUtils;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.webkit.WebView;
+
+public class ApexHistoryActivity extends Activity
+{
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		Log.d("AboutActivity", "onCreate");
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_history);
+
+		WebView wv = (WebView) findViewById(R.id.webView1);
+		String content = "";
+		try
+		{
+			InputStream in = getResources().openRawResource(R.raw.about);
+			// 获取文件的字节数
+			int lenght = in.available();
+			// 创建byte数组
+			byte[] buffer = new byte[lenght];
+			// 将文件中的数据读到byte数组中
+			in.read(buffer);
+			content = EncodingUtils.getString(buffer, "UTF-8");
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+		}
+		wv.getSettings().setDefaultTextEncodingName("UTF-8");
+		wv.loadData(content, "text/html", null);
+		
+	}
+}

+ 25 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ApexPushService.java

@@ -0,0 +1,25 @@
+package com.usai.apex;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+public class ApexPushService extends Service
+{
+
+	
+//	@Override
+//	public void onCreate()
+//	{
+//		
+//		super.onCreate();
+//	}
+
+	@Override
+	public IBinder onBind(Intent intent)
+	{
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

+ 237 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ApexTrackingApplication.java

@@ -0,0 +1,237 @@
+package com.usai.apex;
+
+import com.usai.util.Crypto;
+import com.usai.util.dbUtil;
+
+import android.app.AlarmManager;
+import android.app.Application;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.SystemClock;
+import android.text.TextUtils;
+import android.util.Log;
+
+public class ApexTrackingApplication extends Application
+{
+	static final String						TAG				= "ApexTrackingApplication";
+	private static ApexTrackingApplication	instance;
+	private static String					m_sessionid		= "";
+	private static String					m_user			= "";
+	private static String					m_password		= "";
+	public static int						ncount			= 1;
+
+	private static boolean					m_bauthorized	= false;
+
+	private static long LastAlermTime = -120000;
+	
+	public static void UpdateLastCheckMessageTime()
+	{
+		LastAlermTime = SystemClock.elapsedRealtime();
+	}
+	public static long getLastCheckMessageTime()
+	{
+		return LastAlermTime;
+	}
+	@Override
+	public void onCreate()
+	{
+
+		// TODO Auto-generated method stub
+		Log.d(TAG, "onCreate");
+		super.onCreate();
+		instance = this;
+
+		SharedPreferences pref = ApexTrackingApplication.get_instance()
+				.getSharedPreferences("Apex", 0);
+		boolean autologin = pref.getBoolean("autologin", false);
+		if (autologin == true)
+		{
+
+			String u = pref.getString("user", "");
+			String p = pref.getString("password", "");
+			String s = pref.getString("sessionid", "");
+
+			try
+			{
+				if (!TextUtils.isEmpty(u))
+					m_user = Crypto.decrypt("apexu", u);
+				if (!TextUtils.isEmpty(p))
+					m_password = Crypto.decrypt("apexp", p);
+				if (!TextUtils.isEmpty(s))
+					m_sessionid = Crypto.decrypt("apexp", s);
+			}
+			catch (Exception e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+		}
+		dbUtil.cleanhistory();
+
+		// Intent serviceintent = new Intent();
+		// serviceintent.setClass(this, ApexPushService.class);
+		//
+		//
+		// startService(serviceintent);
+	}
+
+	// @Override
+	// protected void finalize() throws Throwable
+	// {
+	// NotificationManager nManager = (NotificationManager)
+	// instance.getSystemService(
+	// Context.NOTIFICATION_SERVICE);
+	// nManager.cancel(R.layout.activity_apex);
+	// super.finalize();
+	// }
+
+	public static ApexTrackingApplication get_instance()
+	{
+		return instance;
+	}
+
+	public static void startalarm(String caller)
+	{
+		SharedPreferences pref = get_instance()
+				.getSharedPreferences("Apex", 0);
+		boolean autologin = pref.getBoolean("autologin", false);
+		if (autologin == false)
+			return;
+		// 启动完成
+		Intent iAlarm = new Intent(get_instance(), Alarmreceiver.class);
+		iAlarm.putExtra("caller", caller);
+		iAlarm.setAction("com.usai.apex.push");
+		PendingIntent sender = PendingIntent.getBroadcast(get_instance(), 0,
+				iAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
+
+		long firstime = SystemClock.elapsedRealtime();
+//		UpdateLastAlermTime();
+		AlarmManager am = (AlarmManager) get_instance().getSystemService(
+				Context.ALARM_SERVICE);
+
+		// 5分钟一个周期,不停的发送广播
+		am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstime,
+				300 * 1000, sender);
+	}
+
+	public static void cancelalarm()
+	{
+
+		// 启动完成
+		Intent iAlarm = new Intent(get_instance(), Alarmreceiver.class);
+		iAlarm.setAction("com.usai.apex.push");
+		PendingIntent sender = PendingIntent.getBroadcast(get_instance(), 0,
+				iAlarm, PendingIntent.FLAG_UPDATE_CURRENT);
+
+		AlarmManager am = (AlarmManager) get_instance().getSystemService(
+				Context.ALARM_SERVICE);
+
+		am.cancel(sender);
+	}
+
+	public static void logout()
+	{
+		ncount = 1;
+		cancelalarm();
+		m_sessionid = "";
+		m_user = "";
+		m_password = "";
+		m_bauthorized = false;
+		SharedPreferences pref = ApexTrackingApplication.get_instance()
+				.getSharedPreferences("Apex", 0);
+		SharedPreferences.Editor editor = pref.edit();
+
+		editor.putBoolean("autologin", false);
+		editor.commit();
+
+	}
+
+	public static void SetAuthorizeStatus(boolean bauthorized)
+	{
+		m_bauthorized = bauthorized;
+	}
+	public static void login(String sid, String user, String pass)
+	{
+		m_sessionid = sid;
+		m_user = user;
+		m_password = pass;
+		m_bauthorized = true;
+		
+		SharedPreferences pref = ApexTrackingApplication.get_instance()
+				.getSharedPreferences("Apex", 0);
+		SharedPreferences.Editor editor = pref.edit();
+		try
+		{
+
+			editor.putString("user", Crypto.encrypt("apexu", m_user));
+			editor.putString("password", Crypto.encrypt("apexp", m_password));
+			editor.putBoolean("autologin", true);
+			editor.putString("sessionid", Crypto.encrypt("apexp", m_sessionid));
+
+		}
+		catch (Exception e)
+		{
+			editor.putString("user", null);
+			editor.putString("password", null);
+			editor.putString("m_sessionid", null);
+			editor.putBoolean("autologin", false);
+			m_bauthorized=false;
+			e.printStackTrace();
+		}
+		editor.commit();
+
+		startalarm("app Login");
+	}
+
+	// public static void put_sessionid(String id)
+	// {
+	//
+	// Log.e(TAG, "put_sessionid");
+	// m_sessionid = id;
+	// }
+
+	// public static void put_authorization(boolean bauth)
+	// {
+	//
+	// m_bauthorized = bauth;
+	// }
+
+	public static boolean get_authorization()
+	{
+
+		return m_bauthorized;
+	}
+
+	// public static void put_user(String user)
+	// {
+	//
+	// m_user = user;
+	// }
+	//
+	// public static void put_password(String pass)
+	// {
+	//
+	// m_password = pass;
+	// }
+
+	public static String get_sessionid()
+	{
+		Log.d(TAG, "get_sessionid");
+		return m_sessionid;
+	}
+
+	public static String get_user()
+	{
+		Log.d(TAG, "get_user");
+		return m_user;
+	}
+
+	public static String get_pass()
+	{
+		Log.d(TAG, "get_pass");
+		return m_password;
+	}
+}

+ 616 - 0
Apex Mobile/app/src/main/java/com/usai/apex/BaiduMapFragment.java

@@ -0,0 +1,616 @@
+package com.usai.apex;
+
+//import com.google.android.gms.maps.SupportMapFragment;
+
+//import baidumapsdk.demo.DemoApplication;
+//import baidumapsdk.demo.DemoApplication.MyGeneralListener;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+//import baidumapsdk.demo.R;
+
+
+
+
+
+import com.baidu.mapapi.BMapManager;
+import com.baidu.mapapi.SDKInitializer;
+import com.baidu.mapapi.map.BaiduMap.OnMapClickListener;
+import com.baidu.mapapi.map.BitmapDescriptor;
+import com.baidu.mapapi.map.BitmapDescriptorFactory;
+import com.baidu.mapapi.map.InfoWindow;
+import com.baidu.mapapi.map.MapPoi;
+import com.baidu.mapapi.map.MapStatusUpdate;
+import com.baidu.mapapi.map.MapStatusUpdateFactory;
+//import com.baidu.mapapi.MKGeneralListener;
+//import com.baidu.mapapi.map.ItemizedOverlay;
+//import com.baidu.mapapi.map.MKEvent;
+//import com.baidu.mapapi.map.MapController;
+import com.baidu.mapapi.map.MapView;
+import com.baidu.mapapi.map.Marker;
+import com.baidu.mapapi.map.MarkerOptions;
+//import com.baidu.mapapi.map.OverlayItem;
+//import com.baidu.mapapi.map.PopupClickListener;
+//import com.baidu.mapapi.map.PopupOverlay;
+import com.baidu.mapapi.map.SupportMapFragment;
+import com.baidu.mapapi.map.BaiduMap.OnMarkerClickListener;
+import com.baidu.mapapi.map.InfoWindow.OnInfoWindowClickListener;
+import com.baidu.mapapi.model.LatLng;
+//import com.baidu.platform.comapi.basestruct.GeoPoint;
+import com.usai.util.Network;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.drawable.Drawable;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class BaiduMapFragment extends Fragment
+{
+	private SearchTask				m_task				= null;
+	String							fragment_content	= null;
+	private MapView					mMapView			= null;
+	// private MyOverlay mOverlay = null;
+	// private OverlayItem mCurItem = null;
+	// private Button button = null;
+	// private ArrayList<OverlayItem> mItems = null;
+	// private PopupOverlay pop = null;
+	SupportMapFragment				fragment;
+	BMapManager						mBMapManager		= null;
+	public static boolean			m_bKeyRight			= true;
+	HashMap<String, LocationDetail>	marker_detail		= new HashMap<String, LocationDetail>();
+
+	// OverlayItem m_curitem = null;
+	/*
+	 * public class MyOverlay extends ItemizedOverlay {
+	 * 
+	 * public MyOverlay(Drawable defaultMarker, MapView mapView) {
+	 * super(defaultMarker, mapView); }
+	 * 
+	 * @Override public boolean onTap(int index) {
+	 * Log.d("baidumap...................", "ontap"); View viewCache =
+	 * getActivity().getLayoutInflater().inflate( R.layout.marker_view, null);
+	 * 
+	 * TextView tv_title = (TextView) viewCache .findViewById(R.id.tv_title);
+	 * TextView tv_info = (TextView) viewCache.findViewById(R.id.tv_info);
+	 * 
+	 * OverlayItem item = getItem(index);
+	 * 
+	 * tv_title.setText(item.getTitle()); tv_info.setText(item.getSnippet());
+	 * m_curitem = item; pop.showPopup(viewCache, item.getPoint(), 32); return
+	 * true; }
+	 * 
+	 * @Override public boolean onTap(GeoPoint pt, MapView mMapView) {
+	 * Log.d("baidu map demo ", "hide pop"); if (pop != null) {
+	 * 
+	 * pop.hidePop(); // mMapView.removeView(button); } return false; }
+	 * 
+	 * }
+	 */
+
+	void AddMarker()
+	{
+
+		if (mMapView == null)
+		{
+
+			Log.d("onResume", "get map from fragment");
+			mMapView = fragment.getMapView();
+			if (mMapView == null)
+				return;
+		}
+
+		try
+		{
+			JSONObject jsobj = new JSONObject(fragment_content);
+
+			int count = jsobj.getInt("total");
+
+			JSONObject objrecords = jsobj.getJSONObject("records");
+			// mOverlay = new MyOverlay(getResources().getDrawable(
+			// R.drawable.ic_marker), mMapView);
+			BitmapDescriptor icon = BitmapDescriptorFactory
+					.fromResource(R.drawable.ic_marker);
+			for (int i = 0; i < count; i++)
+			{
+				// offset++;
+
+				JSONObject objrec = objrecords.getJSONObject("record" + i);
+				String area = objrec.getString("area");
+				String company = objrec.getString("company");
+				String city = objrec.getString("city");
+				String longitude = objrec.getString("longitude");
+				String latitude = objrec.getString("latitude");
+				String address = objrec.getString("address");
+				String telephone = objrec.getString("telephone");
+				String fax = objrec.getString("fax");
+				String contact = objrec.getString("contact");
+				String email = objrec.getString("email");
+
+				LocationDetail detail = new LocationDetail(company, address,
+						telephone, fax, contact, email);
+				marker_detail.put(company, detail);
+
+				Bundle extrainfo = new Bundle();
+				extrainfo.putString("company", company);
+				extrainfo.putSerializable("detail", detail);
+				extrainfo.putSerializable("city", city);
+				extrainfo.putSerializable("area", area);
+				// // 准备overlay 数据
+				//
+				// GeoPoint p1 = new GeoPoint(
+				// (int) (Double.parseDouble(latitude) * 1E6),
+				// (int) (Double.parseDouble(longitude) * 1E6));
+				// OverlayItem item1 = new OverlayItem(p1, company, city + "\n"
+				// + area);
+				//
+				// //
+				// // * 将item 添加到overlay中 注意: 同一个itme只能add一次
+				// //
+				// mOverlay.addItem(item1);
+				LatLng llA = new LatLng(Double.parseDouble(latitude),
+						Double.parseDouble(longitude));
+
+				MarkerOptions markeroption = new MarkerOptions().position(llA)
+						.icon(icon).zIndex(9).title(company)
+						.extraInfo(extrainfo).draggable(true);
+
+				// if (animationBox.isChecked()) {
+				// //掉下动画
+				// ooA.animateType(MarkerAnimateType.drop);
+				// }
+				Marker mMarkerA = (Marker) (mMapView.getMap()
+						.addOverlay(markeroption));
+
+			}
+			//
+			// * 保存所有item,以便overlay在reset后重新添加
+			//
+			// mItems = new ArrayList<OverlayItem>();
+			// mItems.addAll(mOverlay.getAllItem());
+			// //
+			// // * 将overlay 添加至MapView中
+			// //
+			// mMapView.getOverlays().add(mOverlay);
+			// //
+			// // * 刷新地图
+			// //
+			// mMapView.refresh();
+			// PopupClickListener popListener = new PopupClickListener()
+			// {
+			// @Override
+			// public void onClickedPopup(int index)
+			// {
+			// Log.d("baidu map.......", "popup on click");
+			// pop.hidePop();
+			//
+			// mMapView.refresh();
+			// Intent intent = new Intent();
+			// intent.setClass(getActivity(), LocationDetailActivity.class);
+			//
+			// String markertext = m_curitem.getTitle();
+			//
+			// intent.putExtra("detail", marker_detail.get(markertext));
+			// // // intent.putExtra("password", password);
+			// // intent.putExtra("function_name", function_name);
+			// // intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+			// startActivity(intent);
+			//
+			// }
+			// };
+			// pop = new PopupOverlay(mMapView, popListener);
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	public void requestloactions()
+	{
+
+		if (m_task != null)
+		{
+			return;
+		}
+
+		if (fragment_content != null)
+		{
+			// LayoutInflater inflater = (LayoutInflater)
+			// ApexTrackingApplication
+			// .get_instance().getSystemService(
+			// Context.LAYOUT_INFLATER_SERVICE);
+			// init(fragment_content,inflater);
+			return;
+		}
+		// mStatusMessageView.setText(R.string.str_Loading);
+		// showProgress(true);
+		m_task = new SearchTask();
+
+		// TextView text_page = (TextView) view_page_footer
+		// .findViewById(R.id.text_page);
+		// text_page.setText("Loading...");
+		// text_page.setEnabled(false);
+		m_task.execute();
+
+	}
+
+	class SearchTask extends AsyncTask<Void, Void, Boolean>
+	{
+		int	errorcode;
+
+		// boolean bfinish = false;
+
+		@Override
+		protected Boolean doInBackground(Void... params)
+		{
+			Log.d("SearchTask", "doInBackground");
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+			String jstr = Network.get_servicelocation();
+
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			JSONObject jsobj;
+			//
+			// array = new JSONArray(json);
+			try
+			{
+				jsobj = new JSONObject(jstr);
+				// if (searchresult.get_fieldscount() == 0)
+				// {
+				// JSONObject objfields = jsobj.getJSONObject("fields");
+				// if (objfields != null)
+				// searchresult.init_fields(objfields.toString());
+				// }
+				int count = jsobj.getInt("total");
+				// if (count < limit)
+				// bfinish = true;
+				JSONObject objrecords = jsobj.getJSONObject("records");
+				if (objrecords != null)
+				{
+					fragment_content = jstr;
+					errorcode = Network.RESULT_TRUE;
+
+					return true;
+				}
+			}
+			catch (JSONException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			errorcode = Network.RESULT_NET_ERROR;
+			return false;
+		}
+
+		@Override
+		protected void onPostExecute(Boolean success)
+		{
+			String tag = "onPostExecute@BaiduMapFragment";
+			Log.d(tag, "entry");
+			m_task = null;
+			// showProgress(false);
+
+			switch (errorcode)
+			{
+				case Network.RESULT_NET_NOTAVAILABLE:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_NET_ERROR:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_resulterror),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+
+				default:
+					break;
+			}
+
+			if (success)
+			{
+				AddMarker();
+
+				mMapView.getMap().setOnMapClickListener( new OnMapClickListener()
+				{
+					
+					@Override
+					public boolean onMapPoiClick(MapPoi arg0)
+					{
+						mMapView.getMap().hideInfoWindow();
+						return false;
+					}
+					
+					@Override
+					public void onMapClick(LatLng arg0)
+					{
+						mMapView.getMap().hideInfoWindow();
+						
+					}
+				});
+				mMapView.getMap().setOnMarkerClickListener(
+						new OnMarkerClickListener()
+						{
+							public boolean onMarkerClick(final Marker marker)
+							{
+								// Button button = new
+								// Button(getActivity().getApplicationContext());
+								// button.setBackgroundResource(R.drawable.popup);
+
+								View viewCache = getActivity()
+										.getLayoutInflater().inflate(
+												R.layout.marker_view, null);
+
+								TextView tv_title = (TextView) viewCache
+										.findViewById(R.id.tv_title);
+								TextView tv_info = (TextView) viewCache
+										.findViewById(R.id.tv_info);
+
+								final String title = marker.getTitle();
+
+								Bundle bundle = marker.getExtraInfo();
+
+								final LocationDetail detail = (LocationDetail) bundle
+										.getSerializable("detail");
+								String city = bundle.getString("city");
+								String area = bundle.getString("area");
+								// OverlayItem item = getItem(index);
+
+								// marker.get
+
+								tv_title.setText(title);
+								tv_info.setText(city + "\n" + area);
+								// m_curitem = item;
+								// pop.showPopup(viewCache, item.getPoint(),
+								// 32);
+								OnInfoWindowClickListener listener = null;
+								if (true)
+								{
+									// button.setText("更改位置");
+									listener = new OnInfoWindowClickListener()
+									{
+										public void onInfoWindowClick()
+										{
+
+											mMapView.getMap().hideInfoWindow();
+
+											Log.d("baidu map.......",
+													"popup on click");
+											
+
+//											mMapView.refresh();
+											Intent intent = new Intent();
+											intent.setClass(
+													getActivity(),
+													LocationDetailActivity.class);
+
+											String markertext = title;
+
+											intent.putExtra("detail",
+													detail);
+											// // intent.putExtra("password",
+											// password);
+											// intent.putExtra("function_name",
+											// function_name);
+											// intent.putExtra("behavior",
+											// Network.BEHAVIOR_SEARCH);
+											startActivity(intent);
+										}
+									};
+									LatLng ll = marker.getPosition();
+									InfoWindow mInfoWindow = new InfoWindow(
+											BitmapDescriptorFactory
+													.fromView(viewCache), ll,
+											-100, listener);
+									mMapView.getMap().showInfoWindow(
+											mInfoWindow);
+								}
+								// else if (marker == mMarkerB) {
+								// button.setText("更改图标");
+								// button.setOnClickListener(new
+								// OnClickListener() {
+								// public void onClick(View v) {
+								// marker.setIcon(bd);
+								// mBaiduMap.hideInfoWindow();
+								// }
+								// });
+								// LatLng ll = marker.getPosition();
+								// mInfoWindow = new InfoWindow(button, ll,
+								// -47);
+								// mBaiduMap.showInfoWindow(mInfoWindow);
+								// } else if (marker == mMarkerC) {
+								// button.setText("删除");
+								// button.setOnClickListener(new
+								// OnClickListener() {
+								// public void onClick(View v) {
+								// marker.remove();
+								// mBaiduMap.hideInfoWindow();
+								// }
+								// });
+								// LatLng ll = marker.getPosition();
+								// mInfoWindow = new InfoWindow(button, ll,
+								// -47);
+								// mBaiduMap.showInfoWindow(mInfoWindow);
+								// }
+								return true;
+							}
+						});
+				//
+				// if (bfinish)
+				// {
+				// // getListView().removeFooterView(view_page_footer);
+				// // Toast.makeText(AnnouncementActivity.this, "Load all!",
+				// // Toast.LENGTH_LONG).show();
+				//
+				// TextView tv = (TextView) view_page_footer
+				// .findViewById(R.id.text_page);
+				// tv.setText("No more items");
+				// tv.setEnabled(false);
+				// }
+				// else
+				// {
+				// TextView tv = (TextView) view_page_footer
+				// .findViewById(R.id.text_page);
+				// tv.setText("More...");
+				// tv.setEnabled(true);
+				// }
+				// adapter.notifyDataSetChanged();
+				// // getListAdapter().notifyDataSetChanged;
+				// // BaseAdapter mJson = null;
+				// // mJson.notifyDataSetChanged();
+			}
+
+			super.onPostExecute(success);
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			m_task = null;
+			// showProgress(false);
+		}
+	}
+
+	public void initEngineManager(Context context)
+	{
+
+		SDKInitializer.initialize(ApexTrackingApplication.get_instance());
+		// String strKey = ApexTrackingApplication.get_instance().getString(
+		// R.string.baidu_key);
+		// if (mBMapManager == null)
+		// {
+		// mBMapManager = new BMapManager(context);
+		// }
+		//
+		// if (!mBMapManager.init(strKey, new MyGeneralListener()))
+		// {
+		// // Toast.makeText(getActivity().getApplicationContext(),
+		// // "BMapManager  初始化错误!", Toast.LENGTH_LONG).show();
+		// }
+	}
+
+	/*
+	 * // 常用事件监听,用来处理通常的网络错误,授权验证错误等 static class MyGeneralListener implements
+	 * MKGeneralListener {
+	 * 
+	 * @Override public void onGetNetworkState(int iError) { if (iError ==
+	 * MKEvent.ERROR_NETWORK_CONNECT) { // Toast.makeText( //
+	 * ApexTrackingApplication.get_instance() // .getApplicationContext(),
+	 * "您的网络出错啦!", // Toast.LENGTH_LONG).show(); } else if (iError ==
+	 * MKEvent.ERROR_NETWORK_DATA) { // Toast.makeText( //
+	 * ApexTrackingApplication.get_instance() // .getApplicationContext(),
+	 * "输入正确的检索条件!", // Toast.LENGTH_LONG).show(); } // ... }
+	 * 
+	 * @Override public void onGetPermissionState(int iError) { // 非零值表示key验证未通过
+	 * if (iError != 0) { // 授权Key错误: // Toast.makeText( //
+	 * ApexTrackingApplication.get_instance() // .getApplicationContext(), //
+	 * "请在 DemoApplication.java文件输入正确的授权Key,并检查您的网络连接是否正常!error: " // + iError,
+	 * Toast.LENGTH_LONG).show(); m_bKeyRight = false; } else { m_bKeyRight =
+	 * true; // Toast.makeText( // ApexTrackingApplication.get_instance() //
+	 * .getApplicationContext(), "key认证成功", // Toast.LENGTH_LONG).show(); } } }
+	 */
+	@Override
+	public void onActivityCreated(Bundle savedInstanceState)
+	{
+
+		super.onActivityCreated(savedInstanceState);
+		initEngineManager(getActivity().getApplicationContext());
+
+		FragmentManager fm = getChildFragmentManager();
+		fragment = (SupportMapFragment) fm.findFragmentById(R.id.map);
+
+		if (fragment == null)
+		{
+
+			Log.d("onActivityCreated", "create support map fragment");
+			fragment = SupportMapFragment.newInstance();
+			;// .newInstance();
+			fm.beginTransaction().replace(R.id.map, fragment).commit();
+		}
+		mMapView = fragment.getMapView();
+	}
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState)
+	{
+		// TODO Auto-generated method stub
+		// return super.onCreateView(inflater, container, savedInstanceState);
+				
+
+		requestloactions();
+		return inflater.inflate(R.layout.fragment_service_location, container,
+				false);
+	}
+
+	@Override
+	public void onResume()
+	{
+		super.onResume();
+
+		Log.d("onResume", "get map from fragment");
+		LatLng center = new LatLng(29.945,104.7);
+		MapStatusUpdate msu = MapStatusUpdateFactory.newLatLngZoom(center,4.8f);//MapStatusUpdateFactory.zoomTo(4.5f);
+		
+		
+		fragment.getMapView().getMap().setMapStatus(msu);
+		
+//		float zoomLevel = Float.parseFloat(t.getText().toString());
+//		MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(zoomLevel);
+//		mBaiduMap.animateMapStatus(u);
+//		 MapController controller = fragment.getMapView().getController();
+//		 controller.setCenter(new GeoPoint((int) ( * 1E6),
+//		 (int)  * 1E6)));
+//		 controller.setZoom(5);
+	}
+
+}

+ 55 - 0
Apex Mobile/app/src/main/java/com/usai/apex/BootBroadcastReceiver.java

@@ -0,0 +1,55 @@
+package com.usai.apex;
+
+
+
+
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.ConnectivityManager;
+
+public class BootBroadcastReceiver extends BroadcastReceiver
+{
+
+	@Override
+	public void onReceive(Context context, Intent intent)
+	{
+        if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {  
+//            // 启动完成  
+//            Intent iAlarm = new Intent(context, Alarmreceiver.class);  
+//            iAlarm.setAction("com.usai.apex.push");  
+//            PendingIntent sender = PendingIntent.getBroadcast(context, 0,  
+//            		iAlarm, 0);  
+//            long firstime = SystemClock.elapsedRealtime();  
+//            AlarmManager am = (AlarmManager) context  
+//                    .getSystemService(Context.ALARM_SERVICE);  
+//  
+//            // 10秒一个周期,不停的发送广播  
+//            am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstime,  
+//                    30 * 1000, sender);  
+//			Intent intentservice = new Intent();
+//			intentservice.setClass(context, ApexPushService.class);
+//			if (intent.getExtras() != null)
+//				intentservice.putExtras(intent.getExtras());
+//			intentservice.setAction(intent.getAction());
+//			context.startService(intentservice);
+        	ApexTrackingApplication.startalarm("boot completed");
+        } 
+//		else if (intent.getAction().equals(
+//				ConnectivityManager.CONNECTIVITY_ACTION))
+//		{
+//			
+//			ApexTrackingApplication.startalarm("connection change");
+//			// handle auto submit ,check update etc
+////			dbgUtil.Log(Log.INFO,TAG, "ConnectivityManager.CONNECTIVITY_ACTION");
+////			
+////			new AutoUpdateCheckThread(context, false).start();
+////
+////			new AutoSubmitThread(context).start();
+//
+//		}	       
+        
+	}
+
+}

+ 329 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ChangePasswordActivity.java

@@ -0,0 +1,329 @@
+package com.usai.apex;
+
+import com.usai.util.Network;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * Activity which displays a login screen to the user, offering registration as
+ * well.
+ */
+public class ChangePasswordActivity extends Activity {
+	private UserLoginTask mAuthTask = null;
+
+	// Values for email and password at the time of the login attempt.
+	// private String m_sUser;
+	private String m_soldPassword;
+	private String m_snewPassword;
+	private String m_snew1Password;
+
+	// UI references.
+	private EditText mOldpassView;
+	private EditText mNewpassView;
+	private EditText mNew1passView;
+	private View mLoginFormView;
+	private View mLoginStatusView;
+	private TextView mLoginStatusMessageView;
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+
+		setContentView(R.layout.activity_change_password);
+
+		// Set up the login form.
+
+		mOldpassView = (EditText) findViewById(R.id.old_password);
+
+		mNewpassView = (EditText) findViewById(R.id.new_password);
+		mNew1passView = (EditText) findViewById(R.id.new_password_confirm);
+		mNew1passView
+		 .setOnEditorActionListener(new TextView.OnEditorActionListener() {
+		 @Override
+		 public boolean onEditorAction(TextView textView, int id,
+		 KeyEvent keyEvent) {
+		 if (id == R.id.btn_ok || id == EditorInfo.IME_ACTION_DONE) {
+			 
+			 
+			 InputMethodManager inputMethodManager = (InputMethodManager)getApplicationContext().getSystemService(
+						Context.INPUT_METHOD_SERVICE);
+
+		// EditText editText =
+		// (EditText)findViewById(R.id.xxxx);
+		inputMethodManager.hideSoftInputFromWindow(
+				mNew1passView.getWindowToken(), 0); // ����
+		 changepassword();
+		 return true;
+		 }
+		 return false;
+		 }
+		 });
+
+		mLoginFormView = findViewById(R.id.login_form);
+		mLoginStatusView = findViewById(R.id.login_status);
+		mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);
+
+		findViewById(R.id.btn_ok).setOnClickListener(
+				new View.OnClickListener() {
+					@Override
+					public void onClick(View view) {
+						InputMethodManager inputMethodManager = (InputMethodManager)getApplicationContext().getSystemService(
+								Context.INPUT_METHOD_SERVICE);
+
+				// EditText editText =
+				// (EditText)findViewById(R.id.xxxx);
+				inputMethodManager.hideSoftInputFromWindow(
+						mNew1passView.getWindowToken(), 0); // ����
+						changepassword();
+					}
+				});
+		findViewById(R.id.btn_close).setOnClickListener(
+				new View.OnClickListener() {
+					@Override
+					public void onClick(View view) {
+						finish();
+					}
+				});
+	}
+
+	// @Override
+	// public boolean onCreateOptionsMenu(Menu menu) {
+	// super.onCreateOptionsMenu(menu);
+	// getMenuInflater().inflate(R.menu.change_password, menu);
+	// return true;
+	// }
+	//
+	// /**
+	// * Attempts to sign in or register the account specified by the login
+	// form.
+	// * If there are form errors (invalid email, missing fields, etc.), the
+	// * errors are presented and no actual login attempt is made.
+	// */
+	public void changepassword() {
+		if (mAuthTask != null) {
+			return;
+		}
+
+		// Reset errors.
+		mOldpassView.setError(null);
+		mNewpassView.setError(null);
+		mNew1passView.setError(null);
+
+		// Store values at the time of the login attempt.
+		m_soldPassword = mOldpassView.getText().toString();
+		m_snewPassword = mNewpassView.getText().toString();
+		m_snew1Password = mNew1passView.getText().toString();
+
+		boolean cancel = false;
+		View focusView = null;
+
+		// Check for a valid password.
+		if (TextUtils.isEmpty(m_soldPassword)) {
+			mOldpassView.setError(getString(R.string.error_field_required));
+			focusView = mOldpassView;
+			cancel = true;
+		} else if (TextUtils.isEmpty(m_snewPassword)) {
+			mNewpassView.setError(getString(R.string.error_field_required));
+			focusView = mNewpassView;
+			cancel = true;
+		} else if (TextUtils.isEmpty(m_snew1Password)) {
+			mNew1passView.setError(getString(R.string.error_field_required));
+			focusView = mNew1passView;
+			cancel = true;
+		} else if (m_snewPassword.equals(m_snew1Password)==false) {
+			mNew1passView.setError("New passwords not same");
+			focusView = mNew1passView;
+			cancel = true;
+		}
+
+	
+
+		if (cancel) {
+			// There was an error; don't attempt login and focus the first
+			// form field with an error.
+			focusView.requestFocus();
+		} else {
+			// Show a progress spinner, and kick off a background task to
+			// perform the user login attempt.
+			mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
+			showProgress(true);
+			mAuthTask = new UserLoginTask();
+			mAuthTask.execute((Void) null);
+		}
+	}
+
+	/**
+	 * Shows the progress UI and hides the login form.
+	 */
+	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
+	private void showProgress(final boolean show) {
+		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
+		// for very easy animations. If available, use these APIs to fade-in
+		// the progress spinner.
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
+			int shortAnimTime = getResources().getInteger(
+					android.R.integer.config_shortAnimTime);
+
+			mLoginStatusView.setVisibility(View.VISIBLE);
+			mLoginStatusView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 1 : 0)
+					.setListener(new AnimatorListenerAdapter() {
+						@Override
+						public void onAnimationEnd(Animator animation) {
+							mLoginStatusView.setVisibility(show ? View.VISIBLE
+									: View.GONE);
+						}
+					});
+
+			mLoginFormView.setVisibility(View.VISIBLE);
+			mLoginFormView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 0 : 1)
+					.setListener(new AnimatorListenerAdapter() {
+						@Override
+						public void onAnimationEnd(Animator animation) {
+							mLoginFormView.setVisibility(show ? View.GONE
+									: View.VISIBLE);
+						}
+					});
+		} else {
+			// The ViewPropertyAnimator APIs are not available, so simply show
+			// and hide the relevant UI components.
+			mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
+			mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
+		}
+	}
+
+	/**
+	 * Represents an asynchronous login/registration task used to authenticate
+	 * the user.
+	 */
+	public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
+		int errorcode;
+		@Override
+		protected Boolean doInBackground(Void... params) {
+			errorcode = Network.change_pass(m_soldPassword, m_snewPassword,ApexTrackingApplication.get_user());
+			if (errorcode == Network.RESULT_TRUE)
+				return true;
+			else {
+				return false;
+			}
+		}
+
+		@Override
+		protected void onPostExecute(final Boolean success) {
+			Log.d("onPostExecute", "entry");
+			mAuthTask = null;
+			showProgress(false);
+			// if (netconnect == )
+			// {
+			//
+			// }
+
+			if (success) {
+				AlertDialog.Builder builder = new Builder(ChangePasswordActivity.this);
+				builder.setMessage(getString(R.string.str_password_changed));
+
+				builder.setTitle(getString(R.string.str_change_success));
+
+				builder.setPositiveButton(getString(android.R.string.ok), new OnClickListener() {
+
+					@Override
+					public void onClick(DialogInterface dialog, int which) {
+						dialog.dismiss();
+
+//						ApexTrackingApplication.put_password(m_snewPassword);
+						setResult(Activity.RESULT_OK, null);
+						finish();
+					}
+				});
+
+
+				builder.create().show();
+
+			} else {
+				switch (errorcode) {
+				case Network.RESULT_NET_NOTAVAILABLE: {
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
+				case Network.RESULT_NET_ERROR: {
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_net_resulterror),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
+
+				case Network.RESULT_FALSE: {
+					AlertDialog.Builder builder = new Builder(ChangePasswordActivity.this);
+					builder.setMessage(getString(R.string.str_invalid_password));
+
+					builder.setTitle(getString(R.string.str_failed_to_changepassword));
+
+					builder.setPositiveButton(getString(android.R.string.ok), new OnClickListener() {
+
+						@Override
+						public void onClick(DialogInterface dialog, int which) {
+							dialog.dismiss();
+
+//							RetrievePasswordActivity.this.finish();
+						}
+					});
+					builder.create().show();
+
+					return;
+				}
+				default: {
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_net_resulterror) + ":"
+									+ errorcode, Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				}
+			}
+		}
+
+		@Override
+		protected void onCancelled() {
+			mAuthTask = null;
+			showProgress(false);
+		}
+	}
+}

+ 329 - 0
Apex Mobile/app/src/main/java/com/usai/apex/CustomizeFieldsActivity.java

@@ -0,0 +1,329 @@
+package com.usai.apex;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.usai.util.dbUtil;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
+//import android.content.DialogInterface.OnClickListener;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class CustomizeFieldsActivity extends Activity implements
+		OnClickListener
+{
+	//
+	// @Override
+	// protected void onCreate(Bundle savedInstanceState)
+	// {
+	// super.onCreate(savedInstanceState);
+	// setContentView(R.layout.activity_customize_fields);
+	// }
+	//
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.customize_fields, menu);
+		return true;
+	}
+
+	private static List<fieldedit> list = null;
+	private DragListAdapter adapter = null;
+
+	// public static List<String> groupKey = new ArrayList<String>();
+	private List<fieldedit> showList = new ArrayList<fieldedit>();
+	private List<fieldedit> hideList = new ArrayList<fieldedit>();
+	private String user/* ,password */, function_name;
+	private int behavior;
+
+	public class fieldedit
+	{
+		public String name = null;
+		public int _id = -1;
+
+		public fieldedit(String str, int i)
+		{
+			name = str;
+			_id = i;
+
+		}
+	}
+
+	@Override
+	public void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+
+		user = ApexTrackingApplication.get_user();
+		// password = getIntent().getStringExtra("password");
+		function_name = getIntent().getStringExtra("function_name");
+		behavior = getIntent().getIntExtra("behavior", -1);
+		setContentView(R.layout.activity_customize_fields);
+		Button btnok = (Button) findViewById(R.id.btnok);
+		btnok.setOnClickListener(this);
+		Button btncancel = (Button) findViewById(R.id.btncancel);
+		btncancel.setOnClickListener(this);
+
+		initData();
+
+		DragListView dragListView = (DragListView) findViewById(R.id.drag_list);
+		adapter = new DragListAdapter(this, list);
+		dragListView.setAdapter(adapter);
+		
+		SharedPreferences RunOnce = getSharedPreferences("Apex", 0);
+		
+		String vername;
+		try
+		{
+			vername = getPackageManager().getPackageInfo(
+					"com.usai.apex", 0).versionName;
+			boolean bFirstRun = RunOnce.getBoolean(
+					"FirstRun"+vername+"_fields", true);
+			if(bFirstRun)
+			{
+				SharedPreferences.Editor editor = RunOnce.edit();
+				editor.putBoolean("FirstRun"+vername+"_fields", false);
+				// Don't forget to commit your edits!!!
+				editor.commit();
+				Intent intent = new Intent();
+				intent.setClass(this, HelpActivity.class);
+				intent.putExtra("caller", "fields");
+				startActivity(intent);
+				
+			}		
+		}
+		catch (NameNotFoundException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		switch (item.getItemId())
+		{
+		case R.id.action_help:
+			Intent intent = new Intent();
+			intent.setClass(this, HelpActivity.class);
+			intent.putExtra("caller", "fields");
+//			// intent.putExtra("password", password);
+//			intent.putExtra("function_name", function_name);
+//			intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+			startActivity(intent);
+			break;
+
+		default:
+			break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+	public void initData()
+	{
+		SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
+		Cursor cursor = db.query("fields_info", new String[] { "aname", "show",
+				"_id" }, "function_name='" + function_name + "' and user='"
+				+ user + "' and behavior=" + behavior, null, null, null,
+				"priority , aname", null);
+		while (cursor.moveToNext())
+		{
+			int show = cursor.getInt(1);
+			if (show == 1)
+				showList.add(new fieldedit(cursor.getString(0), cursor
+						.getInt(2)));
+			else
+			{
+				hideList.add(new fieldedit(cursor.getString(0), cursor
+						.getInt(2)));
+
+			}
+		}
+		// ��ݽ��
+		list = new ArrayList<fieldedit>();
+
+		// groupKey��ŵ��Ƿ����ǩ
+		// groupKey.add("Display fields");
+		// groupKey.add("Hide fields");
+
+		// for (int i = 0; i < 5; i++)
+		// {
+		// navList.add("Aѡ��" + i);
+		// }
+		list.add(new fieldedit(getString(R.string.str_displayitem), -1));
+		list.addAll(showList);
+
+		// for (int i = 0; i <18; i++)
+		// {
+		// moreList.add("Bѡ��" + i);
+		// }
+		list.add(new fieldedit(getString(R.string.str_hideitem), -2));
+		list.addAll(hideList);
+		dbUtil.CloseCursor(cursor);
+		dbUtil.CloseDB(db);
+	}
+
+	public static class DragListAdapter extends ArrayAdapter<fieldedit>
+	{
+
+		// private Context mContext;
+
+		public DragListAdapter(Context context, List<fieldedit> objects)
+		{
+			super(context, 0, objects);
+			// this.mContext = context;
+		}
+
+		public List<fieldedit> getList()
+		{
+			return list;
+		}
+
+		@Override
+		public boolean isEnabled(int position)
+		{
+			if (getItem(position)._id < 0) // _id<0 means a group key
+				return false;
+			// if (groupKey.contains(getItem(position).name))
+			// {
+			// // ����Ƿ����ǩ������false������ѡ�У����ܵ��
+			// return false;
+			// }
+			return super.isEnabled(position);
+		}
+
+		public int switchpos()
+		{
+
+			for (int i = 1; i < getCount(); i++)
+			{
+				if (getItem(i)._id < 0)
+					return i;
+			}
+			return -1;
+		}
+
+		@Override
+		public View getView(int position, View convertView, ViewGroup parent)
+		{
+
+			View view = convertView;
+			if (getItem(position)._id < 0) // _id<0 means a group key
+			{
+				view = LayoutInflater.from(getContext()).inflate(
+						R.layout.drag_list_item_tag, null);
+			}
+			// if (groupKey.contains(getItem(position).name))
+			// {
+			// // ����Ƿ����ǩ���ͼ��ط����ǩ�IJ����ļ������������ļ���ʾЧ��ͬ
+			// view = LayoutInflater.from(getContext()).inflate(
+			// R.layout.drag_list_item_tag, null);
+			// }
+			else
+			{
+				// �������������ǩ���ͼ����������IJ����ļ�
+				view = LayoutInflater.from(getContext()).inflate(
+						R.layout.drag_list_item, null);
+			}
+
+			TextView textView = (TextView) view
+					.findViewById(R.id.drag_list_item_text);
+			textView.setText(getItem(position).name);
+
+			return view;
+		}
+	}
+
+	@Override
+	public void onClick(View v)
+	{
+		switch (v.getId())
+		{
+		case R.id.btnok:
+		{
+			// DragListView dragListView = (DragListView)
+			// findViewById(R.id.drag_list);
+			int count = 0;
+			for (int i = 0; i < adapter.getCount(); i++)
+			{
+				fieldedit fe = adapter.getItem(i);
+				if (fe._id == -2 || count > 0)
+					break;
+				if (fe._id >= 0)
+					count++;
+
+			}
+			if (count == 0)
+			{
+				new AlertDialog.Builder(CustomizeFieldsActivity.this)
+						.setIcon(android.R.drawable.ic_dialog_info)
+						.setTitle("Error!")
+						.setMessage("You must set at least 1 field visiable!")
+						.setPositiveButton("OK",
+								new DialogInterface.OnClickListener()
+								{
+									public void onClick(DialogInterface dialog,
+											int whichButton)
+									{
+
+										// finish();
+										/* User clicked OK so do some stuff */
+									}
+								}).show();
+				break;
+
+			}
+
+			int show = 1;
+			SQLiteDatabase db = dbUtil.OpenDB(this, null, true);
+			db.beginTransaction();
+			for (int i = 0; i < adapter.getCount(); i++)
+			{
+				fieldedit fe = adapter.getItem(i);
+				if (fe._id == -2)// hide group begin 
+				{
+					show = 0;
+				}
+				if (show == 1)
+					db.execSQL("update fields_info set show=" + show
+							+ " ,priority=" + i + " where _id=" + fe._id);
+				else
+					db.execSQL("update fields_info set show=" + show
+							+ " where _id=" + fe._id);
+
+			}
+			db.setTransactionSuccessful();
+			db.endTransaction();
+			dbUtil.CloseDB(db);
+			finish();
+			// Log.d("fields",);
+			break;
+		}
+		case R.id.btncancel:
+			finish();
+			break;
+		default:
+			break;
+		}
+		// TODO Auto-generated method stub
+
+	}
+
+}

+ 411 - 0
Apex Mobile/app/src/main/java/com/usai/apex/DetailActivity.java

@@ -0,0 +1,411 @@
+package com.usai.apex;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+
+import com.usai.util.commonUtil;
+import com.usai.util.dbUtil;
+
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+import android.widget.TabHost;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentTransaction;
+
+public class DetailActivity extends FragmentActivity implements
+		TabHost.TabContentFactory
+{
+	boolean showlogin = false;
+	// int radomid = 1 + (int) (Math.random() * 15);
+	TabHost							mTabHost;
+	LinkedHashMap<String, Integer>	tabmap	= new LinkedHashMap<String, Integer>();
+	HashMap<String,String> contentmap = new HashMap<String ,String>();
+
+	// HashMap<String, DetailFragment> fragments = new HashMap<String,
+	// DetailFragment>();
+	String							function_name;
+	String							_id;
+	String							cargo_criterion;
+	int								criterion_type;
+
+	public DetailActivity get_instance()
+	{
+		return this;
+	}
+	public void save_content(String which,String content)
+	{
+		contentmap.put(which, content);
+		
+	}
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		Log.d("DetailActivity", "onCreate");
+
+		super.onCreate(savedInstanceState);
+
+		setContentView(R.layout.activity_detail);
+
+		List<Fragment> fragments = getSupportFragmentManager().getFragments();
+		if (fragments != null)
+		{
+			Log.d("DetailActivity", "fragments count=" + fragments.size());
+//			for (int i = 0; i < fragments.size(); i++)
+//				Log.e("DetailFragment", "fragment name="
+//						+ fragments.get(i).getTag());
+
+		}
+
+		if (savedInstanceState != null)
+		{
+			tabmap = (LinkedHashMap<String, Integer>) savedInstanceState
+					.getSerializable("tabmap");
+			contentmap = (HashMap<String, String>) savedInstanceState.getSerializable("contentmap");
+		}
+		else
+		{
+			int count = getIntent().getIntExtra("actions_count", 0);
+			for (int i = 0; i < count; i++)
+			{
+				int vid = commonUtil.generateViewId();
+				tabmap.put(getIntent().getStringExtra("action" + i), vid);
+			}
+		}
+		function_name = getIntent().getStringExtra("function_name");
+		
+		if(function_name.equals("Ocean Booking"))
+			setTitle("Booking Detail");
+		else if(function_name.equals("Ocean B/L info."))
+			setTitle("B/L info. Detail");
+		else if(function_name.equals("Container detail"))
+			setTitle("Container Detail");
+//		else if(function_name.equals("Cargo Tracking"))
+//			setTitle("Cargo Detail");
+//		
+		
+		if (function_name.equals("Cargo Tracking"))
+		{
+			criterion_type = getIntent().getIntExtra("criterion_type", 0);
+			cargo_criterion = getIntent().getStringExtra("cargo_criterion");
+		}
+		_id = getIntent().getStringExtra("_id");
+		setupTabs();
+
+	}
+
+	// @Override
+	// protected void onSaveInstanceState(Bundle outState)
+	// {
+	// Iterator<String> iter=fragments.keySet().iterator();
+	//
+	// while (iter.hasNext())
+	// {
+	// String tag = (String) iter.next();
+	// getSupportFragmentManager().putFragment(outState,tag,fragments.get(tag));
+	//
+	// }
+	// outState.putStringArray("tags", fragments.keySet().toArray(new
+	// String[0]));
+	// Log.d("onSaveInstanceState","save fragments" +
+	// fragments.keySet().size());
+	// super.onSaveInstanceState(outState);
+	// }
+	//
+	// @Override
+	// protected void onRestoreInstanceState(Bundle savedInstanceState)
+	// {
+	// String [] tags =savedInstanceState.getStringArray("tags");
+	// Log.d("onRestoreInstanceState","load fragments" + tags.length);
+	// for(int i=0;i<tags.length;i++)
+	// {
+	// Log.d("onRestoreInstanceState","load fragment" + tags[i]);
+	// fragments.put(tags[i],(DetailFragment)
+	// getSupportFragmentManager().getFragment(savedInstanceState,tags[i]));
+	// }
+	//
+	// super.onRestoreInstanceState(savedInstanceState);
+	// }
+
+	/** {@inheritDoc} */
+	public View createTabContent(String tag)
+	{
+		FrameLayout fl = new FrameLayout(this);
+		fl.setId(tabmap.get(tag));
+
+		Fragment f;
+		Bundle bundle = new Bundle();
+		if (function_name.equals("Cargo Tracking"))
+		{
+			if (criterion_type == 0)
+				bundle.putString("hbol", cargo_criterion);
+			else
+				bundle.putString("container_no", cargo_criterion);
+
+		}
+		bundle.putString("action_type", tag);
+		bundle.putString("id", _id);
+		bundle.putString("module_name", function_name);
+
+//		Log.e("findFragmentByTag", "tag=" + tag + ", isnull= "
+//				+ (getSupportFragmentManager().findFragmentByTag(tag) == null));
+
+		f = getSupportFragmentManager().findFragmentById(tabmap.get(tag));
+		if (f == null)
+		{
+			Log.d("createTabContent", "create fragment" + tag);
+			f = new DetailFragment();
+
+			
+			f.setArguments(bundle);
+		}
+		((DetailFragment)f).set_content( contentmap.get(tag));
+		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+		ft.replace(fl.getId(), f);
+		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		ft.addToBackStack(tag);
+		ft.commit();
+		return fl;
+	}
+
+	@Override
+	protected void onSaveInstanceState(Bundle outState)
+	{
+		outState.putSerializable("tabmap", tabmap);
+		outState.putSerializable("contentmap", contentmap);
+		super.onSaveInstanceState(outState);
+	}
+
+	// TabHost mTabHost;
+	// private FrameLayout mTabContent;
+	
+//	@Override
+//	public boolean onKeyDown(int keyCode, KeyEvent event)
+//	{
+//		if (keyCode == KeyEvent.KEYCODE_BACK)
+//		{
+//			// Intent myIntent = new Intent();
+//			// myIntent = new Intent(EditActivity.this, tabActivity.class);
+//			// startActivity(myIntent);
+//			finish();
+//			return true;
+//		}
+//		return super.onKeyDown(keyCode, event);
+//	}
+
+	@Override
+	public boolean onKeyUp(int keyCode, KeyEvent event)
+	{
+		if (keyCode == KeyEvent.KEYCODE_BACK)
+		{
+			// Intent myIntent = new Intent();
+			// myIntent = new Intent(EditActivity.this, tabActivity.class);
+			// startActivity(myIntent);
+			finish();
+			return true;
+		}
+		return super.onKeyUp(keyCode, event);
+	}
+	//
+	// @Override
+	// protected void onCreate(Bundle savedInstanceState)
+	// {
+	// super.onCreate(savedInstanceState);
+	// setContentView(R.layout.activity_detail);
+	// // Show the Up button in the action bar.
+	// setupActionBar();
+	// setupTabs();
+	// }
+	//
+	// /**
+	// * Set up the {@link android.app.ActionBar}.
+	// */
+	// private void setupActionBar()
+	// {
+	//
+	// getActionBar().setDisplayHomeAsUpEnabled(true);
+	//
+	// }
+	//
+	// // private View createTabIndicatorView(ViewGroup parent, CharSequence
+	// label, Drawable icon) {
+	// // final LayoutInflater inflater = LayoutInflater.from(this);
+	// // final View tabIndicator = inflater.inflate(R.layout.tab_indicator,
+	// parent, false);
+	// //
+	// //// final TextView tv = (TextView)
+	// tabIndicator.findViewById(R.id.tab_title);
+	// //// tv.setText(label);
+	// ////
+	// //// final ImageView iconView = (ImageView)
+	// tabIndicator.findViewById(R.id.tab_icon);
+	// //// iconView.setImageDrawable(icon);
+	// //
+	// // return tabIndicator;
+	// // }
+	//
+	// @Override
+	// public View createTabContent(String tag)
+	// {
+	// final TextView tv = new TextView(this);
+	// tv.setText("Content for tab with tag " + tag);
+	// return tv;
+	// }
+	private void setupTabs()
+	{
+		mTabHost = (TabHost) findViewById(R.id.tabhost);
+		// mTabContent = (FrameLayout) findViewById(android.R.id.tabcontent);
+		// FrameLayout tab1 = new FrameLayout(this);
+		mTabHost.setup();
+
+		Iterator<String> iter = tabmap.keySet().iterator();
+		while (iter.hasNext())
+		{
+			String name = (String) iter.next();
+			mTabHost.addTab(mTabHost.newTabSpec(name).setIndicator(name)
+					.setContent(this));
+			// String val = (String) tabmap.get(field);
+			// parms.putString(field, val);
+			// // Cursor c = (Cursor) m_listadapter.getItem(key);
+			// Log.d("@@@@@@@@@", field + " : " + val);
+		}
+
+		// for (int i=1; i <= tabmap.size(); i++) {
+		// String name = tabmap.keySet().iterator().;
+		// mTabHost.addTab(mTabHost.newTabSpec(name)
+		// .setIndicator(name)
+		// .setContent(this));
+		// }
+		// // if(true)
+		// // return;
+		//
+		// // View tab1 = createTabIndicatorView(mTabHost.getTabWidget(),
+		// // "Login",null);
+		// // tabhost.addTab(
+		// // tabhost.newTabSpec("tab" + i).setIndicator(tab)
+		// // .setContent(Mytabfirst.this)); tabhost.setCurrentTab(i);
+		// // i++; tab = null;
+		//
+		// // // ��ɵײ��Զ�����ʽ�İ�ť
+		// // String[] title = new String[] { "Login", "Not login" };
+		// // int[] tabIds = new int[] { R.id.tab1, R.id.tab2 };
+		// mTabHost.addTab(mTabHost.newTabSpec("Login").setIndicator("Login")
+		// .setContent(this));
+		// //
+		// mTabHost.addTab(mTabHost.newTabSpec("Direct Tracking").setIndicator("Direct Tracking").setContent(R.id.tab2));
+		// mTabHost.addTab(mTabHost.newTabSpec("Service Location")
+		// .setIndicator("Service Location").setContent(this));
+
+		// FragmentManager manager = this.getFragmentManager();
+
+		// Instantiate a new fragment.
+		// Fragment loginFragment = new LoginFragment();
+		// // Fragment dtFragement = new DirectTrackingFragment();
+		// Fragment slFragment = new ServiceLocationFragment();
+		// // Add the fragment to the activity, pushing this transaction
+		// // on to the back stack.
+		//
+		// FragmentTransaction ft =
+		// getSupportFragmentManager().beginTransaction();
+		// ft.replace(mTabHost.getTabContentView().getChildAt(0).getId(),
+		// loginFragment);
+		// ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		// ft.addToBackStack("Login");
+		//
+		// // ft.replace(R.id.tab2, dtFragement);
+		// // ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		// // ft.addToBackStack("Tracking");
+		//
+		// ft.replace(R.id.tab3, (Fragment) slFragment);
+		// ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		// ft.addToBackStack("Location");
+		//
+		// ft.commit();
+
+		// if (manager.findFragmentByTag(tabId) == null)
+		// {
+		// FragmentTransaction trans = manager.beginTransaction();
+		// trans.replace(contentViewID, frag, tabId);
+		// trans.commit();
+		// }
+		// for (int i = 0; i < title.length; i++) {
+		// Button button = new Button(this);
+		// button.setText(title[i]);
+		// button.setBackgroundDrawable(this.getResources().getDrawable(
+		// R.drawable.tab_lable)); //�Զ��尴ť��ʽ
+		// mTabHost.addTab(mTabHost.newTabSpec(title[i]).setIndicator(button)
+		// .setContent(tabIds[i]));
+		// }
+
+		// mTabHost.setOnTabChangedListener(this);
+	}
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.detail, menu);
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		switch (item.getItemId())
+		{
+			case R.id.action_addto_favorite:
+//	            LayoutInflater factory = LayoutInflater.from(this);
+//	            final View textEntryView = factory.inflate(R.layout.alert_dialog_text_entry, null);
+	            final View edit = new EditText(this);
+	             new AlertDialog.Builder(this)
+	                .setIconAttribute(android.R.attr.alertDialogIcon)
+	                .setTitle(R.string.str_createname)
+	                .setView(edit)
+	                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+	                    public void onClick(DialogInterface dialog, int whichButton) {
+	                    	String name = ((EditText)edit).getText().toString();
+	                    	String param = getIntent().toUri(0);
+	                    	
+	        				SQLiteDatabase db = dbUtil.OpenDB(
+	        						ApexTrackingApplication.get_instance(), null, true);
+	        				db.execSQL("insert into favorites(name,params,user,create_time) values('"
+	        						+ name
+	        						+ "','"
+	        						+ param
+	        						+ "','"
+	        						+ ApexTrackingApplication.get_user()
+	        						+ "',"
+	        						+ System.currentTimeMillis() + ")");
+	        				dbUtil.CloseDB(db);                    	
+	    
+	                        /* User clicked OK so do some stuff */
+	                    }
+	                })
+	                .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
+	                    public void onClick(DialogInterface dialog, int whichButton) {
+
+	                        /* User clicked cancel so do some stuff */
+	                    }
+	                })
+	                .create().show();
+	             return true;
+
+
+		}
+		return super.onOptionsItemSelected(item);
+	}
+
+}

+ 712 - 0
Apex Mobile/app/src/main/java/com/usai/apex/DetailFragment.java

@@ -0,0 +1,712 @@
+package com.usai.apex;
+
+import java.io.File;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+
+import com.usai.util.Network;
+import com.usai.util.commonUtil;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DownloadManager;
+import android.app.AlertDialog.Builder;
+import android.app.DownloadManager.Request;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Environment;
+import android.support.v4.app.Fragment;
+import android.text.Html;
+import android.util.Log;
+import android.util.SparseIntArray;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.webkit.DownloadListener;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class DetailFragment extends Fragment implements OnClickListener /*
+																		 * ,
+																		 * OnGestureListener
+																		 */
+{
+
+	private static final int	REQUEST_LOGINACTIVITY	= 1;
+
+	// DataFragment mdataFragment;
+
+	/* private GestureDetector mGestureDetector; */
+	@Override
+	public void onCreate(Bundle savedInstanceState)
+	{
+		// TODO Auto-generated method stub
+		super.onCreate(savedInstanceState);
+
+	}
+
+	@Override
+	public void onDestroyView()
+	{
+		Log.d("DetailFragment", "onDestroyView()");
+		super.onDestroyView();
+	}
+
+	// public String get_content()
+	// {
+	// return fragment_content;
+	// }
+
+	LinearLayout		ll_root;
+	ScrollView			sl_root;
+	String				mimeType			= "text/html";
+	private SearchTask	m_task				= null;
+	SparseIntArray		control				= new SparseIntArray();
+	// private TextView mStatusMessageView;
+	private View		mStatusView;
+
+	String				fragment_content	= null;
+
+	public void requestdata()
+	{
+
+		if (m_task != null)
+		{
+			return;
+		}
+		if (fragment_content != null)
+		{
+			LayoutInflater inflater = (LayoutInflater) ApexTrackingApplication
+					.get_instance().getSystemService(
+							Context.LAYOUT_INFLATER_SERVICE);
+			init(fragment_content, inflater);
+			return;
+		}
+		// if (mdataFragment.get_result() != null) {
+		// LayoutInflater inflater = (LayoutInflater) ApexTrackingApplication
+		// .get_instance().getSystemService(
+		// Context.LAYOUT_INFLATER_SERVICE);
+		// init(mdataFragment.get_result(), inflater);
+		// }
+		// if (fragment_content != null)
+		// return;
+		// mStatusMessageView.setText("Loading");
+		showProgress(true);
+		m_task = new SearchTask();
+		m_task.execute();
+
+	}
+
+	public void set_content(String content)
+	{
+		fragment_content = content;
+	}
+
+	private void showProgress(final boolean show)
+	{
+		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
+		// for very easy animations. If available, use these APIs to fade-in
+		// the progress spinner.
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
+		{
+			int shortAnimTime = ApexTrackingApplication.get_instance()
+					.getResources()
+					.getInteger(android.R.integer.config_shortAnimTime);
+
+			mStatusView.setVisibility(View.VISIBLE);
+			mStatusView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 1 : 0)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							mStatusView.setVisibility(show ? View.VISIBLE
+									: View.INVISIBLE);
+						}
+					});
+
+			ll_root.setVisibility(View.VISIBLE);
+			ll_root.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							ll_root.setVisibility(show ? View.INVISIBLE
+									: View.VISIBLE);
+						}
+					});
+		}
+		else
+		{
+			// The ViewPropertyAnimator APIs are not available, so simply show
+			// and hide the relevant UI components.
+			mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
+			ll_root.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
+		}
+	}
+
+	// @Override
+	// public void onActivityCreated(Bundle savedInstanceState)
+	// {
+	// FragmentManager fm = getFragmentManager();
+	//
+	// // Check to see if we have retained the worker fragment.
+	// mdataFragment = (DataFragment)fm.findFragmentByTag("work");
+	//
+	// // If not retained (or first time running), we need to create it.
+	// if (mdataFragment == null) {
+	// mdataFragment = new DataFragment();
+	// // Tell it who it is working with.
+	// mdataFragment.setTargetFragment(this, 0);
+	// fm.beginTransaction().add(mdataFragment, "work").commit();
+	// }
+	// super.onActivityCreated(savedInstanceState);
+	// }
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState)
+	{
+		/* mGestureDetector = new GestureDetector(this); */
+		View view = inflater.inflate(R.layout.detail_fragment, null);
+		sl_root = (ScrollView) view.findViewById(R.id.sl_root);
+		/*
+		 * sl_root.setOnTouchListener(new View.OnTouchListener() {
+		 * 
+		 * @Override public boolean onTouch(View v, MotionEvent event) { return
+		 * mGestureDetector.onTouchEvent(event); } });
+		 */
+		ll_root = (LinearLayout) view.findViewById(R.id.ll_root);
+		mStatusView = view.findViewById(R.id.status);
+		LinearLayout ll = (LinearLayout) view.findViewById(R.id.ll_refresh);
+		Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
+		btn_refresh.setOnClickListener(new View.OnClickListener()
+		{
+
+			@Override
+			public void onClick(View v)
+			{
+				LinearLayout ll = (LinearLayout) ll_root
+						.findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.GONE);
+
+				requestdata();
+
+			}
+		});
+		// FragmentManager fm = getFragmentManager();
+		// List<Fragment> fragments = fm.getFragments();
+		// if (fragments != null) {
+		// Log.e("DetailFragment", "fragments count=" + fragments.size());
+		// // for (int i = 0; i < fragments.size(); i++)
+		// // Log.e("DetailFragment", "fragments name=" + fragments.size());
+		//
+		// }
+		// // this.getFragmentManager();
+		// String tag = getArguments().getString("module_name");
+		// // Check to see if we have retained the worker fragment.
+		// mdataFragment = (DataFragment) fm.findFragmentById(12345);
+		//
+		// // If not retained (or first time running), we need to create it.
+		// if (mdataFragment == null) {
+		// Log.e("dataFragment creaded ", "tag=data_" + tag);
+		// mdataFragment = new DataFragment();
+		// // Tell it who it is working with.
+		// mdataFragment.setTargetFragment(this, 0);
+		// fm.beginTransaction().add(12345,mdataFragment, "data+" +
+		// tag).commit();
+		// }
+		requestdata();
+		return view;
+	}
+
+	void init(String jstr, LayoutInflater inflater)
+	{
+		String TAG = "init@DetailFragment";
+		Log.d(TAG, jstr);
+		try
+		{
+			JSONObject jsonObj = new JSONObject(jstr);
+			int group_count = jsonObj.getInt("count");
+			if (group_count == 0)
+			{
+
+				TextView tv_empty = (TextView) ll_root
+						.findViewById(R.id.tv_empty);
+				tv_empty.setVisibility(View.VISIBLE);
+			}
+			for (int i = 0; i < group_count; i++)
+			{
+				// String key = (String) it.next();
+				// if (key.equals("result"))
+				// continue;
+				JSONObject groupobj = jsonObj.getJSONObject("group" + i);
+				View v = inflater.inflate(R.layout.group_tag, null);
+				v.setOnClickListener(this);
+
+				TextView tvgroup = (TextView) v.findViewById(R.id.tv_group);
+				String group_name = groupobj.getString("_name");
+				tvgroup.setText(group_name);
+				v.setId(commonUtil.generateViewId());
+				ll_root.addView(v);
+				String grouptype = groupobj.getString("_type");
+				// groupobj.remove("_type");
+				if (grouptype.equals("mapping"))
+				{
+					LinearLayout mappingview = (LinearLayout) inflater.inflate(
+							R.layout.key_mapping, null);
+					mappingview.setId(commonUtil.generateViewId());
+					control.put(v.getId(), mappingview.getId());
+					ll_root.addView(mappingview);
+
+					int map_count = groupobj.getInt("count");
+					for (int j = 0; j < map_count; j++)
+					{
+						// String keygroup = (String) itgroup.next();
+						JSONObject itemobj = groupobj.getJSONObject("item" + j);
+						String key = (String) itemobj.keys().next();
+						String val = itemobj.getString(key);
+						LinearLayout mappingitem = (LinearLayout) inflater
+								.inflate(R.layout.keymapping_item, null);
+						TextView tvkey = (TextView) mappingitem
+								.findViewById(R.id.tv_key);
+						tvkey.setText(key);
+						// tvkey.setBackgroundResource(R.drawable.detail_item);
+						TextView tvval = (TextView) mappingitem
+								.findViewById(R.id.tv_value);
+						tvval.setText(Html.fromHtml(val));
+						// tvval.setBackgroundResource(R.drawable.detail_item);
+						mappingview.addView(mappingitem);
+					}
+					// Iterator itgroup = groupobj.keys();
+					// while (itgroup.hasNext())
+					// {
+					//
+					//
+					// }
+				}
+				else if (grouptype.equals("table"))
+				{
+					String content = groupobj.getString("content");
+					WebView wv;
+
+					wv = (WebView) inflater.inflate(R.layout.web_content, null);
+
+					wv.getSettings().setDefaultTextEncodingName("UTF-8");
+					wv.setId(commonUtil.generateViewId());
+					wv.setWebViewClient(new MyWebViewClient());
+					wv.setDownloadListener(new DownloadListener()
+					{
+
+						@Override
+						public void onDownloadStart(String url,
+								String userAgent, String contentDisposition,
+								String mimetype, long contentLength)
+						{
+							if(!commonUtil.localdirExist())
+							{
+								
+								new AlertDialog.Builder(getActivity())
+				                .setIconAttribute(android.R.attr.alertDialogIcon)
+				                .setTitle(R.string.str_localdir_error)
+				                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+				                    public void onClick(DialogInterface dialog, int whichButton) {
+
+				                        /* User clicked OK so do some stuff */
+				                    }
+				                })
+				                .create().show();
+								return;
+							}
+							String filename = contentDisposition.replace("attachment;filename=\"", "");
+							filename = filename.replace("\"", "");
+							
+							Log.d("WebView", "Download Action");
+							Log.d("tag", "url=" + url);
+							// Log.i("tag", "userAgent="+userAgent);
+							// Log.i("tag",
+							// "contentDisposition="+contentDisposition);
+							// Log.i("tag", "mimetype="+mimetype);
+							// Log.i("tag", "contentLength="+contentLength);
+							// Uri uri = Uri.parse(url);
+							// Intent intent = new Intent(Intent.ACTION_VIEW,
+							// uri);
+							// startActivity(intent);
+
+							final DownloadManager downloadManager = (DownloadManager) ApexTrackingApplication
+									.get_instance().getSystemService(
+											Context.DOWNLOAD_SERVICE);
+
+							Uri uri = Uri.parse(url);
+							final Request request = new Request(uri);
+
+							// 设置允许使用的网络类型,这里是移动网络和wifi都可以
+							request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
+									| DownloadManager.Request.NETWORK_WIFI);
+							
+							
+							
+							request.setDestinationInExternalPublicDir("Apex Mobile",filename); 
+
+							// 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
+							// request.setShowRunningNotification(false);
+
+							// 不显示下载界面
+							request.setVisibleInDownloadsUi(false);
+							request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
+
+							/*
+							 * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
+							 * 因此最好不设置如果sdcard可用,下载后的文件 在/mnt/sdcard/Android/
+							 * data/packageName/files目录下面
+							 * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个 目录下面
+							 */
+							// request.setDestinationInExternalFilesDir(this,
+							// null, "tar.apk");
+
+//							getActivity();
+							AlertDialog.Builder builder = new Builder(
+									getActivity());
+							builder.setMessage(getString(R.string.str_downloadmessage));
+
+							builder.setTitle(getString(R.string.str_confirmdownload));
+
+							builder.setPositiveButton(
+									getString(R.string.str_download),
+									new Dialog.OnClickListener()
+									{
+
+										@Override
+										public void onClick(
+												DialogInterface dialog,
+												int which)
+										{
+											downloadManager.enqueue(request);
+											dialog.dismiss();
+
+										}
+									});
+
+							builder.setNegativeButton(
+									getString(R.string.str_cancel),
+									new Dialog.OnClickListener()
+									{
+
+										@Override
+										public void onClick(
+												DialogInterface dialog,
+												int which)
+										{
+											dialog.dismiss();
+										}
+									});
+
+							builder.create().show();
+						}
+
+					});
+					control.put(v.getId(), wv.getId());
+					wv.loadData(content, mimeType, null);
+
+					// wv.setOnTouchListener(new OnTouchListener()
+					// {
+					// @Override
+					// public boolean onTouch(View v, MotionEvent event)
+					// {
+					//
+					// if (event.getAction() == MotionEvent.ACTION_UP)
+					// sl_root.requestDisallowInterceptTouchEvent(false);
+					// else
+					// sl_root.requestDisallowInterceptTouchEvent(true);
+					//
+					// return false;
+					// }
+					// });
+					ll_root.addView(wv);
+					Log.d("table content", content);
+
+				}
+				if (grouptype.equals("list"))
+				{
+					LinearLayout listview = (LinearLayout) inflater.inflate(
+							R.layout.list_content, null);
+					listview.setId(commonUtil.generateViewId());
+					control.put(v.getId(), listview.getId());
+					ll_root.addView(listview);
+					long list_count = groupobj.getInt("count");
+					for (int j = 0; j < list_count; j++)
+					{
+						RelativeLayout listitem = (RelativeLayout) inflater
+								.inflate(R.layout.list_item, null);
+
+						TextView tvitem = (TextView) listitem
+								.findViewById(R.id.tv_item);
+						String val = groupobj.getString("line" + j);
+						tvitem.setText(val);
+						// tvitem.setBackgroundResource(R.drawable.detail_item);
+						listitem.removeView(tvitem);
+
+						listview.addView(tvitem);
+					}
+					// Iterator itgroup = groupobj.keys();
+					// while (itgroup.hasNext())
+					// {
+					// String keygroup = (String) itgroup.next();
+					//
+					// }
+				}
+				// String value = obj.getString(key);
+				// JSONArray array = obj.getJSONArray(key);
+				// for(int i=0;i<array.length();i++){
+				// JSONObject jsonobject = array.getJSONObject(i);
+				// jsonobject.put("name", key);
+				// jsonobject.put("exp", key+"="+jsonobject.getString("value"));
+				// newArray.put(jsonobject);
+
+			}
+			// Iterator it = jsonObj.keys();
+			// while (it.hasNext())
+			// {
+			//
+			// }
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+	@Override
+	public void onClick(View v)
+	{
+		View view = ll_root.findViewById(control.get(v.getId()));
+		if (view.getVisibility() == View.VISIBLE)
+			view.setVisibility(View.GONE);
+		else
+			view.setVisibility(View.VISIBLE);
+
+	}
+
+	@Override
+	public void onDestroy()
+	{
+		if (m_task != null)
+			m_task.cancel(true);
+		super.onDestroy();
+	}
+
+	@Override
+	public void onActivityResult(int requestCode, int resultCode, Intent data)
+	{
+		((DetailActivity) getActivity()).showlogin = false;
+		super.onActivityResult(requestCode, resultCode, data);
+	}
+
+	@Override
+	public void onDetach()
+	{
+		if (m_task != null)
+			m_task.cancel(false);
+		super.onDetach();
+	}
+
+	class SearchTask extends AsyncTask<Void, Void, Boolean>
+	{
+		int	errorcode;
+
+		@Override
+		protected Boolean doInBackground(Void... params)
+		{
+			Log.d("SearchTask", "doInBackground");
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+			String jstr = Network.get_detail(getArguments());
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			// mdataFragment.put_result(jstr);
+			fragment_content = jstr;
+			DetailActivity activity = (DetailActivity) getActivity();
+			activity.save_content(getArguments().getString("action_type"), jstr);
+
+			errorcode = Network.RESULT_TRUE;
+
+			return true;
+		}
+
+		@Override
+		protected void onPostExecute(Boolean success)
+		{
+			Log.i("onPostExecute", "entry");
+			m_task = null;
+			showProgress(false);
+
+			if (ApexTrackingApplication.get_authorization() == false)
+			{
+				if(((DetailActivity) getActivity()).showlogin == true)
+					return;
+				((DetailActivity) getActivity()).showlogin = true;
+				LinearLayout ll = (LinearLayout) ll_root
+						.findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.VISIBLE);
+				Toast toast = Toast.makeText(
+						ApexTrackingApplication.get_instance(),
+						getText(R.string.msg_net_passwordchangedremote) , Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				Intent i = new Intent();
+				i.setClass(getActivity(), ApexActivity.class);
+				startActivityForResult(i, REQUEST_LOGINACTIVITY);
+				return;
+			}
+			
+			switch (errorcode)
+			{
+				case Network.RESULT_NET_NOTAVAILABLE:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_NET_ERROR:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_resulterror) + ":"
+									+ errorcode, Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+
+					break;
+				}
+
+				default:
+					break;
+			}
+
+			if (success)
+			{
+				LayoutInflater inflater = (LayoutInflater) ApexTrackingApplication
+						.get_instance().getSystemService(
+								Context.LAYOUT_INFLATER_SERVICE);
+
+				init(fragment_content, inflater/*
+												 * getActivity().
+												 * getLayoutInflater()
+												 */);
+			}
+			else
+			{
+				LinearLayout ll = (LinearLayout) ll_root
+						.findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.VISIBLE);
+			}
+			super.onPostExecute(success);
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			m_task = null;
+			showProgress(false);
+		}
+	}
+
+	// public class DataFragment extends Fragment {
+	//
+	// String result = null;
+	//
+	// @Override
+	// public void onCreate(Bundle savedInstanceState) {
+	// setRetainInstance(true);
+	// super.onCreate(savedInstanceState);
+	// }
+	//
+	// public String get_result() {
+	// return result;
+	//
+	// }
+	//
+	// public void put_result(String s) {
+	// result = s;
+	// }
+	//
+	// }
+
+	public class MyWebViewClient extends WebViewClient
+	{
+		// 如果页面中链接,如果希望点击链接继续在当前browser中响应,
+		// 而不是新开Android的系统browser中响应该链接,必须覆盖 webview的WebViewClient对象。
+		public boolean shouldOverviewUrlLoading(WebView view, String url)
+		{
+			// L.i("shouldOverviewUrlLoading");
+			view.loadUrl(url);
+			return true;
+		}
+
+		public void onPageStarted(WebView view, String url, Bitmap favicon)
+		{
+			// L.i("onPageStarted");
+			// showProgress();
+		}
+
+		public void onPageFinished(WebView view, String url)
+		{
+			// L.i("onPageFinished");
+			// closeProgress();
+		}
+
+		public void onReceivedError(WebView view, int errorCode,
+				String description, String failingUrl)
+		{
+			// L.i("onReceivedError");
+			// closeProgress();
+		}
+	}
+
+}

+ 25 - 0
Apex Mobile/app/src/main/java/com/usai/apex/DocumentsActivity.java

@@ -0,0 +1,25 @@
+package com.usai.apex;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+
+public class DocumentsActivity extends FragmentActivity
+{
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_inner_tools);
+
+		// Fragment f = new ToolsFragment();
+		if (savedInstanceState == null)
+		{
+			getSupportFragmentManager().beginTransaction()
+					.add(R.id.container, new DocumentsFragment()).commit();
+		}
+
+
+	}
+
+}

+ 88 - 0
Apex Mobile/app/src/main/java/com/usai/apex/DocumentsFragment.java

@@ -0,0 +1,88 @@
+package com.usai.apex;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.Intent.ShortcutIconResource;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.util.Log;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+
+public class DocumentsFragment extends ListFragment
+{
+	
+
+	// @Override
+	// public View onCreateView(LayoutInflater inflater, ViewGroup container,
+	// Bundle savedInstanceState)
+	// {
+	// View view = inflater.inflate(R.layout.fragment_tools, null);
+	// // Button btn = (Button) view.findViewById(R.id.btn_cancel);
+	// // btn.setOnClickListener(this);
+	// return view;
+	// // return super.onCreateView(inflater, container, savedInstanceState);
+	// }
+	private List<Map<String, Object>> getData()
+	{
+		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+
+		Map<String, Object> map = new HashMap<String, Object>();
+		map.put("title", "Search document online");
+		map.put("img", R.drawable.rect_search_documents);
+		list.add(map);
+
+		map = new HashMap<String, Object>();
+		map.put("title", "View downloaded document");
+		map.put("img", R.drawable.rect_view_download_documents);
+		list.add(map);
+
+	
+		
+		return list;
+	}
+
+	@Override
+	public void onActivityCreated(Bundle savedInstanceState)
+	{
+		super.onActivityCreated(savedInstanceState);
+		SimpleAdapter adapter = new SimpleAdapter(this.getActivity(),
+				getData(), R.layout.fragment_tools, new String[] { "title",
+						"img" }, new int[] { R.id.tv_toolname, R.id.iv_icon });
+		setListAdapter(adapter);
+		this.getListView().setBackgroundColor(Color.WHITE);
+	}
+
+	@Override
+	public void onListItemClick(ListView l, View v, int position, long id)
+	{
+		Log.d("FragmentList", "Item clicked: " + id);
+		
+		String title = (String) getData().get(position).get("title");
+		Intent intent = new Intent();
+		if(title.equals("Search document online"))
+		{
+			intent.setClass(getActivity(), SearchListActivity.class);
+	
+			intent.putExtra("function_name", "Download Document");
+			intent.putExtra("title", "Document Search");
+
+		}
+		else if(title.equals("View downloaded document"))
+		{
+			intent.setClass(getActivity(), LocalDocumentActivity.class);
+//			intent.putExtra("module_name", "Announcements");
+		}
+
+		
+		startActivity(intent);
+
+	}
+}

+ 282 - 0
Apex Mobile/app/src/main/java/com/usai/apex/DragListView.java

@@ -0,0 +1,282 @@
+package com.usai.apex;
+
+import com.usai.apex.CustomizeFieldsActivity.DragListAdapter;
+import com.usai.apex.CustomizeFieldsActivity.fieldedit;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.graphics.PixelFormat;
+import android.util.AttributeSet;
+import android.view.Gravity;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewConfiguration;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.widget.AdapterView;
+import android.widget.ImageView;
+import android.widget.ListView;
+
+public class DragListView extends ListView
+{
+
+	private ImageView dragImageView;// ����ק�����ʵ����һ��ImageView
+	private int dragSrcPosition;// ��ָ�϶���ԭʼ���б��е�λ��
+	private int dragPosition;// ��ָ�϶���ʱ�򣬵�ǰ�϶������б��е�λ��
+
+	private int dragPoint;// �ڵ�ǰ������е�λ��
+	private int dragOffset;// ��ǰ��ͼ����Ļ�ľ���(����ֻʹ����y������)
+
+	private WindowManager windowManager;// windows���ڿ�����
+	private WindowManager.LayoutParams windowParams;// ���ڿ�����ק�����ʾ�IJ���
+
+	private int scaledTouchSlop;// �жϻ�����һ������
+	private int upScrollBounce;// �϶���ʱ�򣬿�ʼ���Ϲ����ı߽�
+	private int downScrollBounce;// �϶���ʱ�򣬿�ʼ���¹����ı߽�
+
+	public DragListView(Context context, AttributeSet attrs)
+	{
+		super(context, attrs);
+		scaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
+
+		this.setOnItemClickListener(mItemClickListenter);
+	}
+
+	private int lastClickId = -1;
+	private long lastClickTime;
+	private OnItemClickListener mItemClickListenter = new OnItemClickListener()
+	{
+		public void onItemClick(AdapterView<?> parent, View v, int pos, long id)
+		{
+			DragListAdapter adapter = (DragListAdapter) ((ListView) parent)
+					.getAdapter();
+
+			if (adapter.isEnabled(pos) == false)// return if item is a group key
+				return;
+			fieldedit dclickitem = (fieldedit) ((ListView) parent).getAdapter()
+					.getItem(pos);
+
+			// �����˫��,1�����������ж�Ϊ˫��
+			if (dclickitem._id == lastClickId
+					&& (Math.abs(lastClickTime - System.currentTimeMillis()) < 1000))
+			{
+				lastClickId = -1;
+				lastClickTime = 0;
+				if (pos < adapter.switchpos())
+				{
+					adapter.remove(dclickitem);
+					adapter.insert(dclickitem, adapter.getCount());
+				}
+				else
+				{
+					adapter.remove(dclickitem);
+					adapter.insert(dclickitem, 1);
+
+				}
+				// Intent intent = new Intent();
+				// intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+				// intent.putExtra("matchId", mv.getId());
+				// intent.putExtra("matchKey", mv.getMatchKey());
+				// intent.setClass(SenseSoccerScoreActivity.this,
+				// MatchEventActivity.class);
+				// startActivity(intent);
+			}
+			else
+			{
+				lastClickId = dclickitem._id;
+				lastClickTime = System.currentTimeMillis();
+			}
+		}
+	};
+
+	// ����touch�¼�����ʵ���Ǽ�һ�����
+	@Override
+	public boolean onInterceptTouchEvent(MotionEvent ev)
+	{
+		if (ev.getAction() == MotionEvent.ACTION_DOWN)
+		{
+			int x = (int) ev.getX();
+			int y = (int) ev.getY();
+
+			dragSrcPosition = dragPosition = pointToPosition(x, y);
+			if (dragPosition == AdapterView.INVALID_POSITION)
+			{
+				return super.onInterceptTouchEvent(ev);
+			}
+
+			ViewGroup itemView = (ViewGroup) getChildAt(dragPosition
+					- getFirstVisiblePosition());
+			dragPoint = y - itemView.getTop();
+			dragOffset = (int) (ev.getRawY() - y);
+
+			View dragger = itemView.findViewById(R.id.drag_list_item_image);
+			if (dragger != null && x > dragger.getLeft() - 20)
+			{
+				//
+				upScrollBounce = Math.min(y - scaledTouchSlop, getHeight() / 3);
+				downScrollBounce = Math.max(y + scaledTouchSlop,
+						getHeight() * 2 / 3);
+
+				itemView.setDrawingCacheEnabled(true);
+				Bitmap bm = Bitmap.createBitmap(itemView.getDrawingCache());
+				startDrag(bm, y);
+			}
+			return false;
+		}
+		return super.onInterceptTouchEvent(ev);
+	}
+
+	/**
+	 * �����¼�
+	 */
+	@Override
+	public boolean onTouchEvent(MotionEvent ev)
+	{
+		if (dragImageView != null && dragPosition != INVALID_POSITION)
+		{
+			int action = ev.getAction();
+			switch (action)
+			{
+			case MotionEvent.ACTION_UP:
+				int upY = (int) ev.getY();
+				stopDrag();
+				onDrop(upY);
+				break;
+			case MotionEvent.ACTION_MOVE:
+				int moveY = (int) ev.getY();
+				onDrag(moveY);
+				break;
+			default:
+				break;
+			}
+			return true;
+		}
+		// Ҳ������ѡ�е�Ч��
+		return super.onTouchEvent(ev);
+	}
+
+	/**
+	 * ׼���϶�����ʼ���϶����ͼ��
+	 * 
+	 * @param bm
+	 * @param y
+	 */
+	public void startDrag(Bitmap bm, int y)
+	{
+		stopDrag();
+
+		windowParams = new WindowManager.LayoutParams();
+		windowParams.gravity = Gravity.TOP;
+		windowParams.x = 0;
+		windowParams.y = y - dragPoint + dragOffset;
+		windowParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
+		windowParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
+		windowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
+				| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
+				| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+				| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
+		windowParams.format = PixelFormat.TRANSLUCENT;
+		windowParams.windowAnimations = 0;
+
+		ImageView imageView = new ImageView(getContext());
+		imageView.setImageBitmap(bm);
+		windowManager = (WindowManager) getContext().getSystemService("window");
+		windowManager.addView(imageView, windowParams);
+		dragImageView = imageView;
+	}
+
+	/**
+	 * ֹͣ�϶���ȥ���϶����ͷ��
+	 */
+	public void stopDrag()
+	{
+		if (dragImageView != null)
+		{
+			windowManager.removeView(dragImageView);
+			dragImageView = null;
+		}
+	}
+
+	/**
+	 * �϶�ִ�У���Move������ִ��
+	 * 
+	 * @param y
+	 */
+	public void onDrag(int y)
+	{
+		if (dragImageView != null)
+		{
+			windowParams.alpha = 0.8f;
+			windowParams.y = y - dragPoint + dragOffset;
+			windowManager.updateViewLayout(dragImageView, windowParams);
+		}
+		// Ϊ�˱��⻬�����ָ��ߵ�ʱ�򣬷���-1������
+		int tempPosition = pointToPosition(0, y);
+		if (tempPosition != INVALID_POSITION)
+		{
+			dragPosition = tempPosition;
+		}
+
+		// ����
+		int scrollHeight = 0;
+		if (y < upScrollBounce)
+		{
+			scrollHeight = 8;// �������Ϲ���8�����أ����������Ϲ����Ļ�
+		}
+		else
+			if (y > downScrollBounce)
+			{
+				scrollHeight = -8;// �������¹���8�����أ������������Ϲ����Ļ�
+			}
+
+		if (scrollHeight != 0)
+		{
+			// ����������setSelectionFromTop()
+			setSelectionFromTop(dragPosition,
+					getChildAt(dragPosition - getFirstVisiblePosition())
+							.getTop() + scrollHeight);
+		}
+	}
+
+	/**
+	 * �϶����µ�ʱ��
+	 * 
+	 * @param y
+	 */
+	public void onDrop(int y)
+	{
+
+		// Ϊ�˱��⻬�����ָ��ߵ�ʱ�򣬷���-1������
+		int tempPosition = pointToPosition(0, y);
+		if (tempPosition != INVALID_POSITION)
+		{
+			dragPosition = tempPosition;
+		}
+
+		// �����߽紦��
+		if (y < getChildAt(1).getTop())
+		{
+			// �����ϱ߽�
+			dragPosition = 1;
+		}
+		else
+			if (y > getChildAt(getChildCount() - 1).getBottom())
+			{
+				// �����±߽�
+				dragPosition = getAdapter().getCount() - 1;
+			}
+
+		// ��ݽ���
+		if (dragPosition > 0 && dragPosition < getAdapter().getCount())
+		{
+			/* @SuppressWarnings("unchecked") */
+			DragListAdapter adapter = (DragListAdapter) getAdapter();
+			fieldedit dragItem = adapter.getItem(dragSrcPosition);
+			adapter.remove(dragItem);
+			adapter.insert(dragItem, dragPosition);
+			// Toast.makeText(getContext(), adapter.getList().toString(),
+			// Toast.LENGTH_SHORT).show();
+		}
+
+	}
+}

+ 267 - 0
Apex Mobile/app/src/main/java/com/usai/apex/FavoritesFragment.java

@@ -0,0 +1,267 @@
+package com.usai.apex;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.usai.util.dbUtil;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.ListFragment;
+import android.text.format.DateFormat;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.View.OnTouchListener;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+import android.widget.TextView;
+
+public class FavoritesFragment extends ListFragment implements OnTouchListener 
+{
+
+	SearchResult	searchresult	= new SearchResult();
+	BaseAdapter		adapter			= null;
+	private int		pointX, pointY, endX, endY;
+	private int		position, newpos;
+	private Button	curDel_btn;
+
+
+
+	@Override
+	public void onActivityCreated(Bundle savedInstanceState)
+	{
+		super.onActivityCreated(savedInstanceState);
+		adapter = new FavoritesAdapter(searchresult, getActivity());
+
+		getListView().setOnTouchListener(this);
+		setListAdapter(adapter);
+		// this.getListView().setBackgroundColor(Color.WHITE);
+	}
+
+	@Override
+	public void onListItemClick(ListView l, View v, int position, long id)
+	{
+
+		Intent intent = new Intent();
+		// SQLiteDatabase db = dbUtil.OpenDB(getActivity(), null, false);
+		// Cursor c = db.query("favorites", new String[]
+		// {"params"},"_id="+searchresult.getData().get(position).get("_id"),null,
+		// null, null, null);
+		// if(c.moveToNext())
+		// {
+		String uri = (String) searchresult.getData().get(position)
+				.get("params");
+		try
+		{
+			intent = Intent.parseUri(uri, 0);
+
+			startActivity(intent);
+		}
+		catch (URISyntaxException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+
+
+	}
+
+	private class FavoritesAdapter extends BaseAdapter
+	{
+		private LayoutInflater	mInflater;	// 动态布局映射
+											// private SearchResult result;
+
+		// private Context context;
+		// private int i = 0;
+		public FavoritesAdapter(SearchResult result, Context context)
+		{
+			// this.result = result;
+			this.mInflater = LayoutInflater.from(context);
+			SQLiteDatabase db = dbUtil.OpenDB(getActivity(), null, false);
+			Cursor cursor = db.query("favorites", new String[] { "_id",
+					"create_time", "name", "params" }, "user='"
+					+ ApexTrackingApplication.get_user() + "'", null, null,
+					null, "_id desc", null);
+
+			result.add_records(cursor);
+			dbUtil.CloseCursor(cursor);
+			dbUtil.CloseDB(db);
+			// this.result = result;
+			// // this.context = context;
+			// this.mInflater = LayoutInflater.from(context);
+		}
+
+		@Override
+		public View getView(int position, View convertView, ViewGroup parent)
+		{
+			// TODO Auto-generated method stub
+			convertView = mInflater.inflate(R.layout.message_list_item, null);// 根据布局文件实例化view
+
+			TextView message = (TextView) convertView
+					.findViewById(R.id.tv_message);// 找某个控件
+
+			message.setText(searchresult.getData().get(position).get("name")
+					.toString());// 给该控件设置数据(数据从集合类中来)
+			TextView time = (TextView) convertView.findViewById(R.id.tv_time);
+			time.setText(DateFormat.format(
+					getString(R.string.time_format),
+					(Long) searchresult.getData().get(position)
+							.get("create_time")));
+
+			return convertView;
+		}
+
+		@Override
+		public int getCount()
+		{
+			return searchresult.get_count();
+		}
+
+		@Override
+		public Object getItem(int position)
+		{
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		@Override
+		public long getItemId(int position)
+		{
+			// TODO Auto-generated method stub
+			return 0;
+		}
+	}
+
+	class SearchResult
+	{
+		List<Map<String, Object>>	datalist	= new ArrayList<Map<String, Object>>();
+
+		public int get_count()
+		{
+			return datalist.size();
+		}
+
+		public void add_records(Cursor c)
+		{
+			while (c.moveToNext())
+			{
+				long _id = c.getInt(0);
+				long create_time = c.getLong(1);
+				String name = c.getString(2);
+				String params = c.getString(3);
+				Map<String, Object> map = new HashMap<String, Object>();
+				map.put("_id", _id);
+
+				map.put("create_time", create_time);
+				map.put("name", name);
+
+				map.put("params", params);
+
+				datalist.add(map);
+			}
+
+		}
+
+		public List<Map<String, Object>> getData()
+		{
+
+			return datalist;
+		}
+	}
+
+	@Override
+	public boolean onTouch(View v, MotionEvent event)
+	{
+		switch (event.getAction())
+		{
+			case MotionEvent.ACTION_DOWN:
+				System.out.println("====>>>>>>>>>>>>>>ACTION_DOWN"
+						+ MotionEvent.ACTION_DOWN);
+				// 手指按下,计算焦点位于ListView的那个条目
+				pointX = (int) event.getX();
+				pointY = (int) event.getY();
+				// 备注1
+				position = getListView().pointToPosition(pointX, pointY);
+				if (curDel_btn != null)
+				{
+					curDel_btn.setVisibility(View.GONE);
+				}
+				break;
+			case MotionEvent.ACTION_MOVE:
+
+				break;
+			case MotionEvent.ACTION_UP:
+				System.out.println("====>>>>>>>>>>>>>>ACTION_UP"
+						+ MotionEvent.ACTION_UP);
+				endX = (int) event.getX();
+				endY = (int) event.getY();
+				newpos = getListView().pointToPosition(endX, endY);
+				// 原本想着加上这个条件(newpos==position)是不是更精确些,
+				// 经过实践发现,其实我们在滑动listView的列表的时候有时候更渴望有滑动就ok
+				if (Math.abs(endX - pointX) > 100 && newpos == position
+						&& Math.abs(endY - pointY) < 100)
+				{
+					// 获取到ListView第一个可见条目的position
+					int firstVisiblePosition = getListView()
+							.getFirstVisiblePosition();
+
+					// --------------备注2
+					View view = getListView().getChildAt(
+							position - firstVisiblePosition);
+					Button delbtn = (Button) view.findViewById(R.id.btn_del);
+					delbtn.setVisibility(View.VISIBLE);
+					curDel_btn = delbtn;
+					delbtn.setOnClickListener(new View.OnClickListener()
+					{
+
+						@Override
+						public void onClick(View v)
+						{
+							// TODO Auto-generated method stub
+
+							SQLiteDatabase db = dbUtil.OpenDB(getActivity(),
+									null, false);
+							db.execSQL("delete from favorites where _id="
+									+ (Long) searchresult.getData()
+											.get(position).get("_id"));
+							Log.d("sql delete" + position,
+									"delete from push_message where _id="
+											+ (Long) searchresult.getData()
+													.get(position).get("_id"));
+
+							dbUtil.CloseDB(db);
+							searchresult.getData().remove(position);
+							adapter.notifyDataSetChanged();
+						}
+					});
+
+				}
+				break;
+
+			default:
+				break;
+		}
+		return false;
+	}
+}

+ 410 - 0
Apex Mobile/app/src/main/java/com/usai/apex/FunctionSelectActivity.java

@@ -0,0 +1,410 @@
+package com.usai.apex;
+
+import com.usai.util.dbUtil;
+
+import android.app.ActionBar;
+import android.app.Activity;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.Button;
+import android.widget.RadioGroup;
+import android.widget.RadioGroup.OnCheckedChangeListener;
+import android.widget.TextView;
+
+public class FunctionSelectActivity extends FragmentActivity implements
+		OnClickListener, OnCheckedChangeListener
+{
+
+	static final int PASSWORD_CHANGED = 1;
+	private static final int	REQUEST_LOGINACTIVITY			= 1;
+	private static final int	REQUEST_CHANGEPASSWORD_ACTIVITY	= 2;
+	private static final int	REQUEST_TOOLS_ACTIVITY			= 3;
+	ArrayAdapter<String>		adapter							= null;
+	
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		Intent intent = new Intent();
+		switch (item.getItemId())
+		{
+			case R.id.action_settings:
+				intent.setClass(this, SettingsActivity.class);
+				// intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+//				intent.putExtra("function_name", function_name);
+//				intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+				startActivity(intent);
+				break;
+
+			default:
+				break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.function_select, menu);
+		return true;
+	}
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		// user = ApexTrackingApplication.get_user();
+		// password= getIntent().getStringExtra("password");
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.new_function_select);
+
+		ActionBar bar = getActionBar();
+		bar.setTitle("");
+		//
+		TextView tv_booking = (TextView) findViewById(R.id.tv_booking);
+		tv_booking.setOnClickListener(this);
+		TextView tv_info = (TextView) findViewById(R.id.tv_info);
+		tv_info.setOnClickListener(this);
+		TextView tv_detail = (TextView) findViewById(R.id.tv_detail);
+		tv_detail.setOnClickListener(this);
+		// TextView tv_cargo = (TextView)findViewById(R.id.tv_cargo);
+		// tv_cargo.setOnClickListener(this);
+		TextView tv_doc = (TextView) findViewById(R.id.tv_doc);
+		tv_doc.setOnClickListener(this);
+		TextView tv_message = (TextView) findViewById(R.id.tv_message);
+		tv_message.setOnClickListener(this);
+		TextView tv_exit = (TextView) findViewById(R.id.tv_exit);
+		tv_exit.setOnClickListener(this);
+		TextView tv_loc = (TextView) findViewById(R.id.tv_location);
+		tv_loc.setOnClickListener(this);
+		TextView tv_tools = (TextView) findViewById(R.id.tv_tools);
+		tv_tools.setOnClickListener(this);
+		Button btn_search = (Button) findViewById(R.id.btn_search);
+		btn_search.setOnClickListener(this);
+		Button btn_clear = (Button) findViewById(R.id.btn_clear);
+		btn_clear.setOnClickListener(this);
+		RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
+		rg.setOnCheckedChangeListener(this);
+		// AutoCompleteTextView et = (AutoCompleteTextView)
+		// findViewById(R.id.atv_criterion);
+		// if (rg.getCheckedRadioButtonId() == R.id.radio0)
+		// adapter = new ArrayAdapter<String>(this,
+		// android.R.layout.simple_dropdown_item_1line,
+		// dbUtil.get_searchhistory("h_bol"));
+		// else
+		// adapter = new ArrayAdapter<String>(this,
+		// android.R.layout.simple_dropdown_item_1line,
+		// dbUtil.get_searchhistory("ctnr"));
+		// et.setAdapter(adapter);
+		SharedPreferences pref = ApexTrackingApplication.get_instance()
+				.getSharedPreferences("Apex", 0);
+		boolean autologin = pref.getBoolean("autologin", false);
+
+		if (!autologin)
+		{
+			Intent i = new Intent();
+			i.setClass(this, ApexActivity.class);
+			startActivityForResult(i, REQUEST_LOGINACTIVITY);
+		}
+
+	}
+
+	@Override
+	protected void onActivityResult(int requestCode, int resultCode, Intent data)
+	{
+		switch (requestCode)
+		{
+			case REQUEST_LOGINACTIVITY:
+				if (resultCode == Activity.RESULT_CANCELED)
+					finish();
+				break;
+			case REQUEST_TOOLS_ACTIVITY:
+				if (resultCode == PASSWORD_CHANGED)
+				{
+					String UNIQUE_STRING = "com.usai.apex.push.cancel";
+					Intent intent = new Intent(UNIQUE_STRING);
+					sendBroadcast(intent);
+					Intent i = new Intent();
+					i.setClass(this, ApexActivity.class);
+					startActivityForResult(i, REQUEST_LOGINACTIVITY);
+				}
+				break;
+			default:
+				break;
+		}
+
+		super.onActivityResult(requestCode, resultCode, data);
+	}
+
+	@Override
+	protected void onDestroy()
+	{
+		// dbUtil.CloseDB(m_db);
+		super.onDestroy();
+	}
+
+	@Override
+	public void onClick(View v)
+	{
+		String TAG = "onClick@FunctionSelectActivity";
+		Log.d(TAG, "ID=" + v.getId());
+		switch (v.getId())
+		{
+			case R.id.btn_clear:
+			{
+
+				AutoCompleteTextView et = (AutoCompleteTextView) findViewById(R.id.atv_criterion);
+				et.setText("");
+				break;
+
+			}
+			case R.id.btn_search:
+			{
+
+				AutoCompleteTextView et = (AutoCompleteTextView) findViewById(R.id.atv_criterion);
+				// et.clearFocus();
+
+				InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext()
+						.getSystemService(Context.INPUT_METHOD_SERVICE);
+
+				inputMethodManager.hideSoftInputFromWindow(et.getWindowToken(),
+						0);
+				inputMethodManager.hideStatusIcon(et.getWindowToken());
+				String cargo_criterion = et.getText().toString();
+				// if (TextUtils.isEmpty(cargo_criterion))
+				// {
+				// et.setError(getString(R.string.error_field_required));
+				// et.requestFocus();
+				// }
+				// else
+				// {
+				Intent intent = new Intent();
+				intent.setClass(this, DetailActivity.class);
+
+				intent.putExtra("action0", "Tracking");
+				intent.putExtra("function_name", "Cargo Tracking");
+
+				intent.putExtra("cargo_criterion", cargo_criterion);
+				intent.putExtra("actions_count", 1);
+				intent.putExtra("_id", "dumb");
+				String h_field;
+				RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
+				if (rg.getCheckedRadioButtonId() == R.id.radio0)
+				{
+					intent.putExtra("criterion_type", 0);
+					h_field = "h_bol";
+				}
+				else
+				{
+					intent.putExtra("criterion_type", 1);
+					h_field = "ctnr";
+				}
+
+				dbUtil.savehistory(h_field, cargo_criterion);
+
+				startActivity(intent);
+
+				break;
+			}
+			case R.id.tv_booking:
+			{
+				Intent intent = new Intent();
+				intent.setClass(this, SearchListActivity.class);
+				// intent.putExtra("user", ApexTrackingApplication.get_user());
+				// intent.putExtra("password", password);
+				intent.putExtra("function_name", "Ocean Booking");
+				intent.putExtra("title", "Booking Search");
+				startActivity(intent);
+				break;
+			}
+			case R.id.tv_info:
+			{
+				Intent intent = new Intent();
+				intent.setClass(this, SearchListActivity.class);
+				// intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+				intent.putExtra("function_name", "Ocean B/L info.");
+				intent.putExtra("title", "B/L info. Search");
+				startActivity(intent);
+				break;
+			}
+			case R.id.tv_detail:
+			{
+				Intent intent = new Intent();
+				intent.setClass(this, SearchListActivity.class);
+				// intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+				intent.putExtra("function_name", "Container detail");
+				intent.putExtra("title", "Container Search");
+				startActivity(intent);
+				break;
+			}
+
+			case R.id.tv_doc:
+			{
+				Intent intent = new Intent();
+				intent.setClass(this, DocumentsActivity.class);
+				// // intent.putExtra("user", user);
+				// // intent.putExtra("password", password);
+				// intent.putExtra("function_name", "Download Document");
+				// intent.putExtra("title", "Document Search");
+				startActivity(intent);
+				break;
+			}
+			case R.id.tv_message:
+			{
+
+				Intent intent = new Intent();
+				intent.setClass(this, MessageActivity.class);
+				startActivity(intent);
+				//
+				// Intent intent = new Intent();
+				// intent.setClass(this, ChangePasswordActivity.class);
+				// // intent.putExtra("function_name", "Container detail");
+				// startActivityForResult(intent,
+				// REQUEST_CHANGEPASSWORD_ACTIVITY);
+				break;
+			}
+			case R.id.tv_exit:
+			{
+				String UNIQUE_STRING = "com.usai.apex.push.cancel";
+				Intent intent = new Intent(UNIQUE_STRING);
+				// intent.putExtra("key1", "value1");
+				// intent.putExtra("key2", "value2");
+				sendBroadcast(intent);
+
+				// ApexTrackingApplication.cancelalarm();
+				// ApexTrackingApplication.put_password("");
+				// ApexTrackingApplication.put_sessionid("");
+				// ApexTrackingApplication.put_user("");
+
+				Intent i = new Intent();
+				i.setClass(this, ApexActivity.class);
+				startActivityForResult(i, 1);
+
+				// finish();
+				// System.exit(0);
+				break;
+			}
+			case R.id.tv_tools:
+			{
+				Intent intent = new Intent();
+				intent.setClass(this, InnerToolsActivity.class);
+				intent.putExtra("launcher", "inner");
+				startActivityForResult(intent,REQUEST_TOOLS_ACTIVITY);
+				break;
+			}
+			case R.id.tv_location:
+			{
+				Log.d("==============", "start location activity");
+				Intent intent = new Intent();
+				intent.setClass(this, InnerMapActivity.class);
+				// intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+				// intent.putExtra("function_name", "Container detail");
+				startActivity(intent);
+				break;
+			}
+
+			default:
+				break;
+		}
+		// TODO Auto-generated method stub
+
+	}
+
+	// class HistoryAdapter extends SimpleCursorAdapter{
+	//
+	// public HistoryAdapter(Context context, int layout, Cursor c,
+	// String[] from, int[] to)
+	// {
+	// super(context, layout, c, from, to,FLAG_AUTO_REQUERY);
+	// // TODO Auto-generated constructor stub
+	// }
+	//
+	// }
+
+	@Override
+	protected void onResume()
+	{
+		SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
+		int count = dbUtil.get_count(db, "push_message", "read = 0 and user = '"+ApexTrackingApplication.get_user()+"'");
+
+		dbUtil.CloseDB(db);
+		NotificationManager nManager = (NotificationManager) this
+				.getSystemService(Context.NOTIFICATION_SERVICE);
+		nManager.cancel(R.layout.activity_apex);
+		ApexTrackingApplication.ncount=1;
+
+		// Intent intent = new Intent();
+		// intent.setClass(ApexTrackingApplication
+		// .get_instance(), FunctionSelectActivity.class);
+		// Intent addShortcut = new Intent(
+		// "com.android.launcher.action.INSTALL_SHORTCUT");
+		// Parcelable icon = Intent.ShortcutIconResource.fromContext(this,
+		// R.drawable.ic_launcher);
+		// addShortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
+		// getString(R.string.app_name));
+		// addShortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
+		// addShortcut.putExtra("duplicate", 0);
+		// addShortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, icon);
+		// Log.e("uuuuuuuuuuuuuuuurrrrrrrrrrrrrriiiiiiiii",
+		// intent.toUri(MODE_WORLD_WRITEABLE));
+		// sendBroadcast(addShortcut);
+		if (count > 0)
+		{
+			TextView tv_message = (TextView) findViewById(R.id.tv_message);
+			tv_message.setCompoundDrawablesWithIntrinsicBounds(0,
+					R.drawable.ic_message_new, 0, 0);
+
+		}
+		else
+		{
+			TextView tv_message = (TextView) findViewById(R.id.tv_message);
+			tv_message.setCompoundDrawablesWithIntrinsicBounds(0,
+					R.drawable.ic_message, 0, 0);
+		}
+
+		RadioGroup rg = (RadioGroup) findViewById(R.id.radioGroup1);
+		AutoCompleteTextView et = (AutoCompleteTextView) findViewById(R.id.atv_criterion);
+		if (rg.getCheckedRadioButtonId() == R.id.radio0)
+			adapter = new ArrayAdapter<String>(this,
+					android.R.layout.simple_dropdown_item_1line,
+					dbUtil.get_searchhistory("h_bol"));
+		else
+			adapter = new ArrayAdapter<String>(this,
+					android.R.layout.simple_dropdown_item_1line,
+					dbUtil.get_searchhistory("ctnr"));
+		et.setAdapter(adapter);
+		super.onResume();
+	}
+
+	@Override
+	public void onCheckedChanged(RadioGroup group, int checkedId)
+	{
+
+		AutoCompleteTextView et = (AutoCompleteTextView) findViewById(R.id.atv_criterion);
+		if (checkedId == R.id.radio0)
+			adapter = new ArrayAdapter<String>(this,
+					android.R.layout.simple_dropdown_item_1line,
+					dbUtil.get_searchhistory("h_bol"));
+		else
+			adapter = new ArrayAdapter<String>(this,
+					android.R.layout.simple_dropdown_item_1line,
+					dbUtil.get_searchhistory("ctnr"));
+		et.setAdapter(adapter);
+
+	}
+
+}

+ 48 - 0
Apex Mobile/app/src/main/java/com/usai/apex/HelpActivity.java

@@ -0,0 +1,48 @@
+package com.usai.apex;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.ImageView;
+
+public class HelpActivity extends Activity implements OnClickListener
+{
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_help);
+		String caller=getIntent().getStringExtra("caller");
+		ImageView iv= (ImageView) findViewById(R.id.iv_help);
+		iv.setOnClickListener(this);
+		if(caller.equals("fields"))
+			iv.setImageResource(R.drawable.help_fields);
+		else if(caller.equals("search"))
+			iv.setImageResource(R.drawable.help_search);
+		else if(caller.equals("result"))
+			iv.setImageResource(R.drawable.help_result);
+	}
+	
+	
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.help, menu);
+		return true;
+	}
+
+
+
+	@Override
+	public void onClick(View v)
+	{
+		finish();
+		
+	}
+
+}

+ 289 - 0
Apex Mobile/app/src/main/java/com/usai/apex/HistoryFragment.java

@@ -0,0 +1,289 @@
+package com.usai.apex;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+
+import com.usai.util.dbUtil;
+
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.ListFragment;
+import android.text.TextUtils;
+import android.text.format.DateFormat;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.View.OnTouchListener;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class HistoryFragment extends ListFragment implements OnTouchListener
+{
+	SearchResult	searchresult	= new SearchResult();
+	BaseAdapter		adapter			= null;
+	private int		pointX, pointY, endX, endY;
+	private int		position, newpos;
+	private Button	curDel_btn;	
+	@Override
+	public void onActivityCreated(Bundle savedInstanceState)
+	{
+		super.onActivityCreated(savedInstanceState);
+		adapter = new HistoryAdapter(searchresult, getActivity());
+
+		getListView().setOnTouchListener(this);
+		setListAdapter(adapter);
+//		this.getListView().setBackgroundColor(Color.WHITE);
+	}
+
+	@Override
+	public void onListItemClick(ListView l, View v, int position, long id)
+	{
+
+		Intent intent = new Intent();
+		String uri = (String) searchresult.getData().get(position).get("params");
+		String searchParms = (String) searchresult.getData().get(position).get("criterion");
+		try
+		{
+//			Bundle bundle = new Bundle();
+			intent = Intent.parseUri(uri, 0);
+			Bundle parms = new Bundle();
+//			parms.writeToParcel(parcel, flags)
+			JSONObject obj = new JSONObject(searchParms);
+			Iterator<?> it = obj.keys();
+			while (it.hasNext())
+			{
+
+				String key = (String) it.next();
+				parms.putString(key, obj.getString(key));
+
+//					obj.put(key, searchParms.get(key).toString());
+
+
+
+			}
+			intent.putExtra("searchParms", parms);
+//			obj.toString();
+			
+			intent.putExtra("columns",
+					dbUtil.get_fields(ApexTrackingApplication.get_user(), (String) searchresult.getData().get(position).get("module_name")));
+			startActivity(intent);
+		}
+		catch (URISyntaxException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		
+
+	}
+	
+	private class HistoryAdapter extends BaseAdapter
+	{
+		private LayoutInflater	mInflater;	// 动态布局映射
+											// private SearchResult result;
+
+		// private Context context;
+		// private int i = 0;
+		public HistoryAdapter(SearchResult result, Context context)
+		{
+			// this.result = result;
+			this.mInflater = LayoutInflater.from(context);
+			SQLiteDatabase db = dbUtil
+					.OpenDB(getActivity(), null, false);
+			Cursor cursor = db.query("history",
+					new String[] { "_id", "create_time", "criterion",
+							"params","module_name" ,"name"}, "user='"
+							+ ApexTrackingApplication.get_user() + "'", null,
+					null, null, "_id desc", null);
+
+			result.add_records(cursor);
+			dbUtil.CloseCursor(cursor);
+			dbUtil.CloseDB(db);
+			// this.result = result;
+			// // this.context = context;
+			// this.mInflater = LayoutInflater.from(context);
+		}
+
+		@Override
+		public View getView(int position, View convertView, ViewGroup parent)
+		{
+			// TODO Auto-generated method stub
+			convertView = mInflater.inflate(R.layout.message_list_item, null);// 根据布局文件实例化view
+
+			TextView message = (TextView) convertView
+					.findViewById(R.id.tv_message);// 找某个控件
+
+			String name = (String) searchresult.getData().get(position).get("name");
+			if(TextUtils.isEmpty(name))
+			{
+				name = "";
+			}
+			message.setText(name);// 给该控件设置数据(数据从集合类中来)
+			TextView time = (TextView) convertView.findViewById(R.id.tv_time);
+			time.setText(DateFormat.format(
+					getString(R.string.time_format),
+					(Long) searchresult.getData().get(position)
+							.get("create_time")));
+
+
+			return convertView;
+		}
+
+		@Override
+		public int getCount()
+		{
+			return searchresult.get_count();
+		}
+
+		@Override
+		public Object getItem(int position)
+		{
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		@Override
+		public long getItemId(int position)
+		{
+			// TODO Auto-generated method stub
+			return 0;
+		}
+	}
+	class SearchResult
+	{
+		List<Map<String, Object>>	datalist	= new ArrayList<Map<String, Object>>();
+
+		public int get_count()
+		{
+			return datalist.size();
+		}
+
+		public void add_records(Cursor c)
+		{
+			while (c.moveToNext())
+			{
+				long _id = c.getInt(0);
+				long create_time = c.getLong(1);
+				String criterion = c.getString(2);
+				String params = c.getString(3);
+				String module_name = c.getString(4);
+				String name = c.getString(5);
+				Map<String, Object> map = new HashMap<String, Object>();
+				map.put("_id", _id);
+				
+				map.put("create_time", create_time);
+				map.put("criterion", criterion);
+				
+				map.put("params", params);
+				map.put("module_name", module_name);
+				map.put("name", name);
+
+				datalist.add(map);
+			}
+
+		}
+
+		public List<Map<String, Object>> getData()
+		{
+
+			return datalist;
+		}
+	}
+	@Override
+	public boolean onTouch(View v, MotionEvent event)
+	{
+		switch (event.getAction())
+		{
+			case MotionEvent.ACTION_DOWN:
+				System.out.println("====>>>>>>>>>>>>>>ACTION_DOWN"
+						+ MotionEvent.ACTION_DOWN);
+				// 手指按下,计算焦点位于ListView的那个条目
+				pointX = (int) event.getX();
+				pointY = (int) event.getY();
+				// 备注1
+				position = getListView().pointToPosition(pointX, pointY);
+				if (curDel_btn != null)
+				{
+					curDel_btn.setVisibility(View.GONE);
+				}
+				break;
+			case MotionEvent.ACTION_MOVE:
+
+				break;
+			case MotionEvent.ACTION_UP:
+				System.out.println("====>>>>>>>>>>>>>>ACTION_UP"
+						+ MotionEvent.ACTION_UP);
+				endX = (int) event.getX();
+				endY = (int) event.getY();
+				newpos = getListView().pointToPosition(endX, endY);
+				// 原本想着加上这个条件(newpos==position)是不是更精确些,
+				// 经过实践发现,其实我们在滑动listView的列表的时候有时候更渴望有滑动就ok
+				if (Math.abs(endX - pointX) > 100 && newpos == position
+						&& Math.abs(endY - pointY) < 100)
+				{
+					// 获取到ListView第一个可见条目的position
+					int firstVisiblePosition = getListView()
+							.getFirstVisiblePosition();
+
+					// --------------备注2
+					View view = getListView().getChildAt(
+							position - firstVisiblePosition);
+					Button delbtn = (Button) view.findViewById(R.id.btn_del);
+					delbtn.setVisibility(View.VISIBLE);
+					curDel_btn = delbtn;
+					delbtn.setOnClickListener(new View.OnClickListener()
+					{
+
+						@Override
+						public void onClick(View v)
+						{
+							// TODO Auto-generated method stub
+
+							SQLiteDatabase db = dbUtil.OpenDB(
+									getActivity(), null, false);
+							db.execSQL("delete from history where _id="
+									+ (Long) searchresult.getData()
+											.get(position).get("_id"));
+							Log.d("sql delete" + position,
+									"delete from push_message where _id="
+											+ (Long) searchresult.getData()
+													.get(position).get("_id"));
+
+							dbUtil.CloseDB(db);
+							searchresult.getData().remove(position);
+							adapter.notifyDataSetChanged();
+						}
+					});
+
+				}
+				break;
+
+			default:
+				break;
+		}
+		return false;
+	}
+}

+ 185 - 0
Apex Mobile/app/src/main/java/com/usai/apex/InnerMapActivity.java

@@ -0,0 +1,185 @@
+package com.usai.apex;
+
+import com.baidu.mapapi.BMapManager;
+//import com.baidu.mapapi.MKGeneralListener;
+//import com.baidu.mapapi.map.MKEvent;
+import com.baidu.mapapi.map.SupportMapFragment;
+
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.widget.Toast;
+
+public class InnerMapActivity extends FragmentActivity
+{
+//	public static boolean		m_bKeyRight				= true;
+//	BMapManager					mBMapManager			= null;
+
+//    public String strKey = getString(R.string.baidu_key);//"nqBQoSDbxrslhuzW91uViQX7";//release
+	private static final String	LTAG					= "test";
+	SupportMapFragment			map;
+
+	boolean						m_bhasgoogleframework	= true;  
+
+//	static class MyGeneralListener implements MKGeneralListener
+//	{
+//
+//		@Override
+//		public void onGetNetworkState(int iError)
+//		{
+//			if (iError == MKEvent.ERROR_NETWORK_CONNECT)
+//			{
+//				Toast.makeText(
+//						ApexTrackingApplication.get_instance()
+//								.getApplicationContext(),
+//						"????????????????????????", Toast.LENGTH_LONG).show();
+//			}
+//			else if (iError == MKEvent.ERROR_NETWORK_DATA)
+//			{
+//				Toast.makeText(
+//						ApexTrackingApplication.get_instance()
+//								.getApplicationContext(),
+//						"??????????????????????????????", Toast.LENGTH_LONG)
+//						.show();
+//			}
+//			// ...
+//		}
+//
+//		@Override
+//		public void onGetPermissionState(int iError)
+//		{
+//			// ???????????????key???????????????
+//			if (iError != 0)
+//			{
+//				// ??????Key?????????
+//				Toast.makeText(
+//						ApexTrackingApplication.get_instance()
+//								.getApplicationContext(),
+//						"?????? MyApplication.java???????????????????????????Key,??????????????????????????????????????????error: "
+//								+ iError, Toast.LENGTH_LONG).show();
+//				m_bKeyRight = false;
+//			}
+//			else
+//			{
+//				m_bKeyRight = true;
+//				Toast.makeText(
+//						ApexTrackingApplication.get_instance()
+//								.getApplicationContext(), "key????????????",
+//						Toast.LENGTH_LONG).show();
+//			}
+//		}
+//	}
+
+	@Override
+	public boolean onKeyDown(int keyCode, KeyEvent event)
+	{
+		if (keyCode == KeyEvent.KEYCODE_BACK)
+		{
+			// Intent myIntent = new Intent();
+			// myIntent = new Intent(EditActivity.this, tabActivity.class);
+			// startActivity(myIntent);
+			finish();
+			return true;
+		}
+		return super.onKeyDown(keyCode, event);
+	}
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		PackageInfo packageInfo;
+		try
+		{
+			packageInfo = this.getPackageManager().getPackageInfo(
+					"com.google.android.gms", 0);
+
+		}
+		catch (NameNotFoundException e)
+		{
+			packageInfo = null;
+			e.printStackTrace();
+		}
+		if (packageInfo == null)
+		{
+			m_bhasgoogleframework = false;
+			System.out.println("没有安装");
+		}
+		else
+		{
+			m_bhasgoogleframework = true;
+			System.out.println("已经安装");
+		}
+		// setUpMapIfNeeded();
+
+//		m_bhasgoogleframework = false;
+		
+		
+		
+
+
+
+		Fragment slFragment = null;
+		if (m_bhasgoogleframework )
+		{
+			setContentView(R.layout.activity_inner_map);
+			slFragment = new ServiceLocationFragment();
+
+			FragmentTransaction ft = getSupportFragmentManager()
+					.beginTransaction();
+			ft.replace(R.id.inner_map, slFragment);
+			ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+			ft.addToBackStack("Location");
+			ft.commit();
+		}
+		else
+		{
+//			if (mBMapManager == null)
+//			{
+//				mBMapManager = new BMapManager(getApplicationContext());
+//				/**
+//				 * ??????BMapManager???????????????????????????BMapManager
+//				 */
+//				mBMapManager.init(strKey, new MyGeneralListener());
+//			}
+			
+//			f.initEngineManager(this);
+			setContentView(R.layout.activity_inner_map);
+//			Log.d(LTAG, "onCreate");
+//			// setContentView(R.layout.activity_main);
+//			map = SupportMapFragment.newInstance();
+			BaiduMapFragment f  = new BaiduMapFragment();
+			FragmentManager manager = getSupportFragmentManager();
+			manager.beginTransaction().add(R.id.inner_map, f, "map_fragment")
+					.commit();
+		}
+	}
+
+	// @Override
+	// public boolean onCreateOptionsMenu(Menu menu)
+	// {
+	// // Inflate the menu; this adds items to the action bar if it is present.
+	// getMenuInflater().inflate(R.menu.inner_map, menu);
+	// return true;
+	// }
+	// private void setUpMapIfNeeded() {
+	// // Do a null check to confirm that we have not already instantiated the
+	// map.
+	// if (mMap == null) {
+	// // Try to obtain the map from the SupportMapFragment.
+	// mMap = ((SupportMapFragment)
+	// getSupportFragmentManager().findFragmentById(R.id.map))
+	// .getMap();
+	// // Check if we were successful in obtaining the map.
+	// if (mMap != null) {
+	// setUpMap();
+	// }
+	// }
+	// }
+}

+ 35 - 0
Apex Mobile/app/src/main/java/com/usai/apex/InnerToolsActivity.java

@@ -0,0 +1,35 @@
+package com.usai.apex;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.support.v4.app.FragmentActivity;
+import android.util.Log;
+
+public class InnerToolsActivity extends FragmentActivity
+{
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_inner_tools);
+
+		// Fragment f = new ToolsFragment();
+		if (savedInstanceState == null)
+		{
+			ToolsFragment f = new ToolsFragment();
+			Bundle b = new Bundle();
+			b.putBoolean("Login", true);
+			f.setArguments(b);
+			getSupportFragmentManager().beginTransaction()
+					.add(R.id.container, f).commit();
+		}
+
+
+	}
+
+}

+ 203 - 0
Apex Mobile/app/src/main/java/com/usai/apex/LocalDocumentActivity.java

@@ -0,0 +1,203 @@
+package com.usai.apex;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.usai.util.commonUtil;
+
+import android.app.ListActivity;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+
+public class LocalDocumentActivity extends ListActivity
+{
+	public static final String FILETYPE ="pdf";
+	private List<Map<String, Object>> getData()
+	{
+		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+
+		
+	
+        if(commonUtil.localdirExist())
+        {
+        	File path = new File(Environment.getExternalStorageDirectory().getPath()+"/Apex Mobile");
+            //返回文件夹中有的数据
+            File[] files = path.listFiles();
+            //先判断下有没有权限,如果没有权限的话,就不执行了
+            if(null == files)
+                return list;
+            for(int i = 0; i < files.length; i++)
+            {
+//				String filePath = files[i].getAbsolutePath();
+				String fileName = files[i].getName();
+				String[] token = fileName.split("\\.");
+				String ext = token[token.length-1];
+				if(!FILETYPE.contains(ext))
+					continue;
+
+				Map<String, Object> map = new HashMap<String, Object>();
+				map.put("title", fileName);
+				map.put("ext", ext);
+				if(ext.toLowerCase().equals("pdf"))
+					map.put("img", R.drawable.ic_pdf128);
+				else
+					map.put("img", R.drawable.ic_file128);
+				list.add(map);
+
+            }
+        }
+		return list;
+	}
+
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.message_list);
+
+		SimpleAdapter adapter = new DocumentsAdapter(this,
+				getData(), R.layout.documents_list_item, new String[] { "title",
+						"img" }, new int[] { R.id.tv_toolname, R.id.iv_icon });
+		setListAdapter(adapter);
+		this.getListView().setBackgroundColor(Color.WHITE);		
+		
+	}
+
+	@Override
+	public void onListItemClick(ListView l, View v, int position, long id)
+	{
+		Log.d("FragmentList", "Item clicked: " + id);
+		String filename = (String) getData().get(position).get("title");
+		Intent intent = new Intent("android.intent.action.VIEW");
+
+		intent.addCategory("android.intent.category.DEFAULT");
+
+		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+		Uri uri = Uri.fromFile(new File(Environment
+				.getExternalStorageDirectory().getPath()
+				+ "/Apex Mobile/"
+				+ filename));
+
+		intent.setDataAndType(uri, "application/"+(String) getData().get(position).get("ext"));
+//	    startActivity(intent);
+	    startActivity(Intent.createChooser(intent,getString(R.string.str_openfile)));
+//		
+//		Intent intent = new Intent();
+//		if(title.equals("Search documents online"))
+//		{
+//			intent.setClass(this, SearchListActivity.class);
+//	
+//			intent.putExtra("function_name", "Download Document");
+//			intent.putExtra("title", "Document Search");
+//
+//		}
+//		else if(title.equals("View download documents"))
+//		{
+//			intent.setClass(this, AnnouncementActivity.class);
+//			intent.putExtra("module_name", "Announcements");
+//		}
+//
+//		
+//		startActivity(intent);
+
+	}
+	
+	private class DocumentsAdapter extends SimpleAdapter
+	{
+
+//		private LayoutInflater	mInflater;
+		@Override
+		public View getView( int position, View convertView, ViewGroup parent)
+		{
+			convertView =super.getView(position, convertView, parent);
+			// TODO Auto-generated method stub
+//			convertView = mInflater.inflate(R.layout.announcement_item, null);// 根据布局文件实例化view
+
+			ImageView iv = (ImageView)convertView.findViewById(R.id.iv_share);
+			iv.setTag( (String) getData().get(position).get("title"));
+			iv.setOnClickListener(new OnClickListener()
+			{
+				
+				@Override
+				public void onClick(View v)
+				{
+					Intent share = new Intent(Intent.ACTION_SEND);   
+					String filename = (String) v.getTag();
+					share.putExtra(Intent.EXTRA_STREAM, 
+					Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+"/Apex Mobile/"+filename)));
+					String[] token = filename.split("\\.");
+					String ext = token[token.length-1];
+					share.setType("application/"+ext);//此处可发送多种文件
+					startActivity(Intent.createChooser(share,getString(R.string.str_sendto)));
+					
+				}
+			});
+//			TextView title = (TextView) convertView.findViewById(R.id.tv_title);// 找某个控件
+//			title.setText(result.getData().get(position).get("title")
+//					.toString());// 给该控件设置数据(数据从集合类中来)
+//			TextView content = (TextView) convertView
+//					.findViewById(R.id.tv_content);
+//			content.setText(result.getData().get(position).get("content")
+//					.toString());
+//			if (result.getData().get(position).get("image").toString().length() > 0)
+//			{
+//				byte[] gzipBuff = Base64.decode(result.getData().get(position)
+//						.get("image").toString(), 0);
+//
+//				ByteArrayInputStream memstream = new ByteArrayInputStream(
+//						gzipBuff, 0, gzipBuff.length);
+//
+//				ByteArrayOutputStream baos = new ByteArrayOutputStream(
+//						gzipBuff.length);
+//				ImageView iv_thumb = (ImageView) convertView
+//						.findViewById(R.id.iv_thumb);
+//				try
+//				{
+//					baos.write(gzipBuff);
+//
+//					Bitmap bmp = BitmapFactory.decodeStream(memstream);
+//
+//					// ImageView image = new ImageView(this);
+//
+//					iv_thumb.setImageBitmap(bmp);
+//				}
+//				catch (IOException e)
+//				{
+//					// TODO Auto-generated catch block
+//					e.printStackTrace();
+//				}
+//			}
+//			// img.setBackgroundResource((Integer)jObject.get("img"));
+
+			return convertView;
+		}
+		public DocumentsAdapter(Context context,
+				List<? extends Map<String, ?>> data, int resource,
+				String[] from, int[] to)
+		{
+			
+			super(context, data, resource, from, to);
+			
+//			this.mInflater = LayoutInflater.from(context);
+			// TODO Auto-generated constructor stub
+		}
+		
+	}
+}

+ 29 - 0
Apex Mobile/app/src/main/java/com/usai/apex/LocationDetail.java

@@ -0,0 +1,29 @@
+package com.usai.apex;
+
+import java.io.Serializable;
+
+public class LocationDetail implements Serializable
+{
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -8043239175565480418L;
+	public String Name,Addr,Tel,Fax,Contact,Email;
+	LocationDetail(String name,String addr,String tel,String fax,String contact,String email)
+	{
+//		Name="aa";
+//		Addr="aa";
+//		Tel="aa";
+//		Fax="aa";
+//		Contact="aa";
+//		Email="aa";
+		Name=name;
+		Addr=addr;
+		Tel=tel;
+		Fax=fax;
+		Contact=contact;
+		Email=email;
+		
+	}
+
+}

+ 174 - 0
Apex Mobile/app/src/main/java/com/usai/apex/LocationDetailActivity.java

@@ -0,0 +1,174 @@
+package com.usai.apex;
+
+import java.util.List;
+
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Email;
+import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.Contacts;
+import android.provider.ContactsContract.Data;
+//import android.provider.Contacts;
+import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.database.Cursor;
+import android.util.Log;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class LocationDetailActivity extends Activity
+{
+	LocationDetail	detail;
+
+	boolean isIntentAvailable(Context context, Intent intent)
+	{
+		final PackageManager packageManager = context.getPackageManager();
+		List<ResolveInfo> list = packageManager.queryIntentActivities(intent,
+				PackageManager.GET_ACTIVITIES);
+		return list.size() > 0;
+	}
+
+	public int getContactid(String name)
+	{
+		int _id = -1;
+
+		Cursor cursor = getContentResolver()
+				.query(Data.CONTENT_URI,
+						new String[] { Data._ID, Data.DISPLAY_NAME,
+								Data.DISPLAY_NAME_ALTERNATIVE,
+								Data.DISPLAY_NAME_SOURCE }, Data.DISPLAY_NAME+"='"+name+"'", null, null);
+
+		Log.d("", "contact " + Data.DISPLAY_NAME + name);
+
+		// Uri uri =
+		// Uri.parse("content://com.android.contacts/data/name/filter/" +
+		// number);
+		// ContentResolver resolver = getContentResolver();
+		// Cursor cursor = resolver.query(uri, new String[]{"_id"}, null, null,
+		// null);
+		while (cursor.moveToNext())
+		{
+			Log.d("", "cursor=" + cursor.getString(1) + cursor.getString(2)
+					+ cursor.getString(3));
+			_id = cursor.getInt(0);
+
+		}
+		cursor.close();
+		return _id;
+	}
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_location_detail);
+		detail = (LocationDetail) getIntent().getSerializableExtra("detail");
+		TextView tv_name = (TextView) findViewById(R.id.tv_name);
+		tv_name.setText(detail.Name);
+		// tv_name.setMovementMethod(LinkMovementMethod.getInstance());
+		TextView tv_addr = (TextView) findViewById(R.id.tv_addr);
+		tv_addr.setText(getString(R.string.str_address)+detail.Addr);
+		// tv_name.setMovementMethod(LinkMovementMethod.getInstance());
+		TextView tv_tel = (TextView) findViewById(R.id.tv_tel);
+		tv_tel.setText(getString(R.string.str_tel)+detail.Tel);
+		// tv_name.setMovementMethod(LinkMovementMethod.getInstance());
+		TextView tv_fax = (TextView) findViewById(R.id.tv_fax);
+		tv_fax.setText(getString(R.string.str_fax)+detail.Fax);
+		// tv_name.setMovementMethod(LinkMovementMethod.getInstance());
+		TextView tv_contact = (TextView) findViewById(R.id.tv_contact);
+		tv_contact.setText(getString(R.string.str_contact)+detail.Contact);
+		// tv_name.setMovementMethod(LinkMovementMethod.getInstance());
+		TextView tv_email = (TextView) findViewById(R.id.tv_email);
+		tv_email.setText(getString(R.string.str_email)+detail.Email);
+		// tv_name.setMovementMethod(LinkMovementMethod.getInstance());
+
+		Button btn = (Button) findViewById(R.id.btn_addcontact);
+		btn.setOnClickListener(new OnClickListener()
+		{
+
+			@Override
+			public void onClick(View v)
+			{
+
+				int _id = getContactid(detail.Name);
+				Log.d("", "contact id = " + _id);
+				Intent it = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, 
+		                ContactsContract.Contacts.CONTENT_URI); 
+				it.setData(Uri.parse("tel:"+detail.Tel));
+				it.putExtra(ContactsContract.Intents.EXTRA_FORCE_CREATE, true);
+//				it.setType(ContactsContract.Contacts.CONTENT_TYPE);// .People.CONTENT_TYPE);
+				it.putExtra(ContactsContract.Intents.Insert.COMPANY,
+						detail.Name);
+				
+				
+				String tel[] = detail.Tel.split("\n");
+				if(tel.length>0)
+				{
+					it.putExtra(ContactsContract.Intents.Insert.PHONE, tel[0]);
+					it.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, Phone.TYPE_WORK);
+				}
+				if(tel.length>1)
+				{
+					it.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE, tel[1]);
+					it.putExtra(ContactsContract.Intents.Insert.SECONDARY_PHONE_TYPE, Phone.TYPE_WORK);
+				}
+				if(tel.length>2)
+				{
+					it.putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE, tel[2]);
+					it.putExtra(ContactsContract.Intents.Insert.TERTIARY_PHONE_TYPE, Phone.TYPE_WORK);
+				}
+				String email[] = detail.Email.split("\n");
+				if(email.length>0)
+				{
+					it.putExtra(ContactsContract.Intents.Insert.EMAIL, email[0]);
+					it.putExtra(ContactsContract.Intents.Insert.EMAIL_TYPE, Email.TYPE_WORK);
+				}
+				if(email.length>1)
+				{
+					it.putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL, email[1]);
+					it.putExtra(ContactsContract.Intents.Insert.SECONDARY_EMAIL_TYPE, Email.TYPE_WORK);
+				}
+				if(email.length>2)
+				{
+					it.putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL, email[2]);
+					it.putExtra(ContactsContract.Intents.Insert.TERTIARY_EMAIL_TYPE, Email.TYPE_WORK);
+				}
+				//
+//				intent.putExtra(Contacts.Intents.Insert.PHONE_TYPE,
+//						Contacts.PhonesColumns.TYPE_MOBILE);
+//				it.putExtra(ContactsContract.Intents.Insert.EMAIL, detail.Email);
+//				it.putExtra(ContactsContract.Intents.Insert.COMPANY,
+//						detail.Name);
+				it.putExtra(ContactsContract.Intents.Insert.POSTAL, detail.Addr);
+
+				if (!isIntentAvailable(LocationDetailActivity.this, it))
+				{
+					Toast.makeText(LocationDetailActivity.this,
+							"failed to add contact", Toast.LENGTH_LONG).show();
+					return;
+				}
+
+				startActivity(it);
+
+			}
+		});
+	}
+
+//	@Override
+//	public boolean onCreateOptionsMenu(Menu menu)
+//	{
+//		// Inflate the menu; this adds items to the action bar if it is present.
+//		getMenuInflater().inflate(R.menu.location_detail, menu);
+//		return true;
+//	}
+
+}

+ 434 - 0
Apex Mobile/app/src/main/java/com/usai/apex/LoginFragment.java

@@ -0,0 +1,434 @@
+package com.usai.apex;
+
+//import android.app.Fragment;
+
+import com.usai.util.Crypto;
+import com.usai.util.Network;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.app.Activity;
+//import android.app.Fragment;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.AsyncTask;
+import android.os.Build;
+//import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.TextView;
+//import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * Activity which displays a login screen to the user, offering registration as
+ * well.
+ */
+public class LoginFragment extends Fragment/* implements OnClickListener */
+{
+	private String m_sUser;
+	private String m_sPassword;
+	private EditText m_etName;
+	private EditText m_etPassword;
+	private UserLoginTask mAuthTask = null;
+	private TextView mLoginStatusMessageView;
+	private View mLoginFormView;
+	private View mLoginStatusView;
+
+	private CheckBox m_cbSave;
+
+	// SQLiteDatabase m_db;
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState) {
+		View view = inflater.inflate(R.layout.fragment_login, null);
+		TextView tv_ver = (TextView) view.findViewById(R.id.tv_ver);
+		try {
+			tv_ver.setText(getText(R.string.str_ver)+ApexTrackingApplication.get_instance().getPackageManager().getPackageInfo(
+						"com.usai.apex", 0).versionName);
+		} catch (NameNotFoundException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+		// Button btn = (Button) view.findViewById(R.id.sign_in_button);
+		// btn.setOnClickListener(this);
+
+		// m_cbSave.setOnCheckedChangeListener(new OnCheckedChangeListener()
+		// {
+		//
+		// @Override
+		// public void onCheckedChanged(CompoundButton buttonView,
+		// boolean isChecked)
+		// {
+		// if (isChecked)
+		// {
+		// String user,password;
+		// SharedPreferences RunOnce = ApexTrackingApplication
+		// .get_instance().getSharedPreferences("Apex", 0);
+		// SharedPreferences.Editor editor = RunOnce.edit();
+		// editor.putString("user", user);
+		// editor.putString("password", user);
+		// }
+		// String vername;
+		// try
+		// {
+		// vername = ApexTrackingApplication.get_instance()
+		// .getPackageManager()
+		// .getPackageInfo("com.usai.apex", 0).versionName;
+		// boolean bFirstRun = RunOnce.getBoolean("FirstRun" + vername
+		// + "_result", true);
+		// if (bFirstRun)
+		// {
+		// SharedPreferences.Editor editor = RunOnce.edit();
+		// editor.putBoolean("FirstRun" + vername + "_result",
+		// false);
+		// // Don't forget to commit your edits!!!
+		// editor.commit();
+		// Intent intent = new Intent();
+		// intent.setClass(this, HelpActivity.class);
+		// intent.putExtra("caller", "result");
+		// startActivity(intent);
+		//
+		// }
+		// }
+		// catch (NameNotFoundException e)
+		// {
+		// // TODO Auto-generated catch block
+		// e.printStackTrace();
+		// }
+		//
+		// }
+		//
+		// });
+		// Set up the login form.
+		// mUser = getIntent().getStringExtra(EXTRA_EMAIL);
+		m_etName = (EditText) view.findViewById(R.id.user);
+		// mUserView.setText(mUser);
+
+		m_etPassword = (EditText) view.findViewById(R.id.password);
+
+		m_cbSave = (CheckBox) view.findViewById(R.id.cb_save);
+		SharedPreferences pref = ApexTrackingApplication.get_instance()
+				.getSharedPreferences("Apex", 0);
+		String u = pref.getString("user", null);
+		String p = pref.getString("password", null);
+		if (u != null && p != null) {
+			try {
+				m_etName.setText(Crypto.decrypt("apexu", u));
+				m_etPassword.setText(Crypto.decrypt("apexp", p));
+				m_cbSave.setChecked(true);
+			} catch (Exception e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+
+		}
+		m_etPassword
+				.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+					@Override
+					public boolean onEditorAction(TextView textView, int id,
+							KeyEvent keyEvent) {
+						if (id == R.id.login
+								|| id == EditorInfo.IME_ACTION_DONE) {
+							InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
+									.getApplicationContext().getSystemService(
+											Context.INPUT_METHOD_SERVICE);
+
+							// EditText editText =
+							// (EditText)findViewById(R.id.xxxx);
+							inputMethodManager.hideSoftInputFromWindow(
+									m_etPassword.getWindowToken(), 0); // ����
+							attemptLogin();
+							return true;
+						}
+						return false;
+					}
+				});
+
+		mLoginFormView = view.findViewById(R.id.login_form);
+		mLoginStatusView = view.findViewById(R.id.login_status);
+		mLoginStatusMessageView = (TextView) view
+				.findViewById(R.id.login_status_message);
+
+		view.findViewById(R.id.sign_in_button).setOnClickListener(
+				new View.OnClickListener() {
+					@Override
+					public void onClick(View view) {
+						InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
+								.getApplicationContext().getSystemService(
+										Context.INPUT_METHOD_SERVICE);
+
+						// EditText editText =
+						// (EditText)findViewById(R.id.xxxx);
+						inputMethodManager.hideSoftInputFromWindow(
+								m_etPassword.getWindowToken(), 0);
+						attemptLogin();
+						// showProgress(true);
+					}
+				});
+		
+		view.findViewById(R.id.tv_retrieve_pass).setOnClickListener(
+				new View.OnClickListener() {
+					@Override
+					public void onClick(View view) {
+						Intent intent = new Intent();
+						intent.setClass(getActivity(), RetrievePasswordActivity.class);
+						startActivity(intent);
+						// showProgress(true);
+					}
+				});
+		return view;
+		// return super.onCreateView(inflater, container, savedInstanceState);
+	}
+
+	// /**
+	// * Attempts to sign in or register the account specified by the login
+	// form.
+	// * If there are form errors (invalid email, missing fields, etc.), the
+	// * errors are presented and no actual login attempt is made.
+	// */
+	public void attemptLogin() {
+		if (mAuthTask != null) {
+			return;
+		}
+
+		// Reset errors.
+		m_etName.setError(null);
+		m_etPassword.setError(null);
+
+		// Store values at the time of the login attempt.
+		m_sUser = m_etName.getText().toString();
+		m_sPassword = m_etPassword.getText().toString();
+
+		boolean cancel = false;
+		View focusView = null;
+
+		// Check for a valid password.
+		if (TextUtils.isEmpty(m_sPassword)) {
+			m_etPassword.setError(getString(R.string.error_field_required));
+			focusView = m_etPassword;
+			cancel = true;
+		} /*else if (m_sPassword.length() < 4) {
+			m_etPassword.setError(getString(R.string.error_invalid_password));
+			focusView = m_etPassword;
+			cancel = true;
+		}*/
+
+		// Check for a valid user name.
+		if (TextUtils.isEmpty(m_sUser)) {
+			m_etName.setError(getString(R.string.error_field_required));
+			focusView = m_etName;
+			cancel = true;
+		}
+		// else if (!m_sName.contains("@")) {
+		// m_etName.setError(getString(R.string.error_invalid_email));
+		// focusView = m_etName;
+		// cancel = true;
+		// }
+
+		if (cancel) {
+			// There was an error; don't attempt login and focus the first
+			// form field with an error.
+			focusView.requestFocus();
+		} else {
+			// Show a progress spinner, and kick off a background task to
+			// perform the user login attempt.
+			mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
+			showProgress(true);
+			mAuthTask = new UserLoginTask();
+			mAuthTask.execute((Void) null);
+		}
+	}
+
+	//
+	// /**
+	// * Shows the progress UI and hides the login form.
+	// */
+	// @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
+	private void showProgress(final boolean show) {
+		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
+		// for very easy animations. If available, use these APIs to fade-in
+		// the progress spinner.
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
+			int shortAnimTime = getResources().getInteger(
+					android.R.integer.config_shortAnimTime);
+
+			mLoginStatusView.setVisibility(View.VISIBLE);
+			mLoginStatusView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 1 : 0)
+					.setListener(new AnimatorListenerAdapter() {
+						@Override
+						public void onAnimationEnd(Animator animation) {
+							mLoginStatusView.setVisibility(show ? View.VISIBLE
+									: View.INVISIBLE);
+						}
+					});
+
+			mLoginFormView.setVisibility(View.VISIBLE);
+			mLoginFormView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 0 : 1)
+					.setListener(new AnimatorListenerAdapter() {
+						@Override
+						public void onAnimationEnd(Animator animation) {
+							mLoginFormView.setVisibility(show ? View.INVISIBLE
+									: View.VISIBLE);
+						}
+					});
+		} else {
+			// The ViewPropertyAnimator APIs are not available, so simply show
+			// and hide the relevant UI components.
+			mLoginStatusView
+					.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
+			mLoginFormView.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
+		}
+	}
+
+	//
+	// /**
+	// * Represents an asynchronous login/registration task used to authenticate
+	// * the user.
+	// */
+	public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
+		// int err_code = ERR_CODE_NONE;
+		int errorcode;
+
+		@Override
+		protected Boolean doInBackground(Void... params) {
+			errorcode = Network.get_Auth(m_sUser, m_sPassword);
+			if (errorcode == Network.RESULT_TRUE)
+				return true;
+			else {
+				return false;
+			}
+
+		}
+
+		@Override
+		protected void onPostExecute(final Boolean success) {
+			Log.d("onPostExecute", "entry");
+			mAuthTask = null;
+			showProgress(false);
+			// if (netconnect == )
+			// {
+			//
+			// }
+
+			if (success) {
+
+				// SharedPreferences.Editor editor = RunOnce.edit();
+				// editor.putBoolean("FirstRun"+globalUtil.getVerName(this),
+				// false);
+				// // Don't forget to commit your edits!!!
+				// editor.commit();
+				SharedPreferences pref = ApexTrackingApplication.get_instance()
+						.getSharedPreferences("Apex", 0);
+				SharedPreferences.Editor editor = pref.edit();
+
+				try {
+					if (m_cbSave.isChecked()) {
+						editor.putString("user",
+								Crypto.encrypt("apexu", m_sUser));
+						editor.putString("password",
+								Crypto.encrypt("apexp", m_sPassword));
+						editor.putBoolean("autologin", true);
+					} else {
+						editor.putString("user", null);
+						editor.putString("password", null);
+						editor.putBoolean("autologin", false);
+					}
+				} catch (Exception e) {
+					editor.putString("user", null);
+					editor.putString("password", null);
+					editor.putBoolean("autologin", false);
+					e.printStackTrace();
+				}
+				editor.commit();
+
+//				Intent intent = new Intent();
+//				intent.setClass(getActivity(), FunctionSelectActivity.class);
+////				intent.putExtra("user", m_sUser);
+////				intent.putExtra("password", m_sPassword);
+//				startActivity(intent);
+				getActivity().setResult(Activity.RESULT_OK, null);
+				getActivity().finish();
+			} else {
+				switch (errorcode) {
+				case Network.RESULT_NET_NOTAVAILABLE: {
+					Toast toast = Toast.makeText(getActivity()
+							.getApplicationContext(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
+				case Network.RESULT_NET_ERROR: {
+					Toast toast = Toast.makeText(getActivity()
+							.getApplicationContext(),
+							getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
+				case Network.RESULT_VER_LOW:
+				{
+					Toast toast = Toast.makeText(getActivity()
+							.getApplicationContext(),
+							getText(R.string.msg_ver_low), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+					Toast toast = Toast.makeText(getActivity()
+							.getApplicationContext(),
+							getText(R.string.msg_net_resulterror),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					return;
+				}
+
+				case Network.RESULT_FALSE: {
+					m_etPassword
+							.setError(getString(R.string.error_incorrect_password));
+					m_etPassword.requestFocus();
+					return;
+					
+				}
+				default: {
+					Toast toast = Toast.makeText(getActivity()
+							.getApplicationContext(),
+							getText(R.string.msg_net_resulterror) + ":"
+									+ errorcode, Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				}
+			}
+		}
+
+		@Override
+		protected void onCancelled() {
+			mAuthTask = null;
+			showProgress(false);
+		}
+	}
+}

+ 370 - 0
Apex Mobile/app/src/main/java/com/usai/apex/MessageActivity.java

@@ -0,0 +1,370 @@
+package com.usai.apex;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.usai.util.Network;
+import com.usai.util.dbUtil;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.ListActivity;
+import android.app.NotificationManager;
+import android.app.AlertDialog.Builder;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.text.format.DateFormat;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnTouchListener;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class MessageActivity extends ListActivity implements OnTouchListener
+{
+	SearchResult	searchresult	= new SearchResult();
+	BaseAdapter		adapter			= null;
+
+	private int		pointX, pointY, endX, endY;
+	private int		position, newpos;
+	private Button	curDel_btn;
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.message, menu);
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		// Intent intent = new Intent();
+		switch (item.getItemId())
+		{
+			case R.id.action_deleteall:
+			{
+				AlertDialog.Builder builder = new Builder(this);
+				builder.setMessage(getString(R.string.str_deletemessage));
+
+				builder.setTitle(getString(R.string.str_confirmdelete));
+
+				builder.setPositiveButton(getString(R.string.str_del),
+						new Dialog.OnClickListener()
+						{
+
+							@Override
+							public void onClick(DialogInterface dialog,
+									int which)
+							{
+								SQLiteDatabase db = dbUtil.OpenDB(
+										MessageActivity.this, null, false);
+								db.execSQL("delete from push_message");
+								Log.d("sql delete" + position,
+										"delete from push_message where _id="
+												+ (Long) searchresult.getData()
+														.get(position)
+														.get("_id"));
+
+								dbUtil.CloseDB(db);
+								dialog.dismiss();
+								searchresult.getData().clear();// .remove(position);
+								adapter.notifyDataSetChanged();
+								NotificationManager nManager = (NotificationManager) 
+										getSystemService(Context.NOTIFICATION_SERVICE);
+								nManager.cancel(R.layout.activity_apex);
+								ApexTrackingApplication.ncount=1;
+							}
+						});
+
+				builder.setNegativeButton(getString(R.string.str_cancel),
+						new Dialog.OnClickListener()
+						{
+
+							@Override
+							public void onClick(DialogInterface dialog,
+									int which)
+							{
+								dialog.dismiss();
+							}
+						});
+
+				builder.create().show();
+
+				break;
+			}
+			case R.id.action_markallread:
+			{
+				SQLiteDatabase db = dbUtil.OpenDB(
+						MessageActivity.this, null, false);
+				db.execSQL("update push_message set read = 1 where user = '"+ApexTrackingApplication.get_user()+"'");
+				Log.d("sql delete" + position,
+						"delete from push_message where _id="
+								+ (Long) searchresult.getData()
+										.get(position)
+										.get("_id"));
+
+				dbUtil.CloseDB(db);
+				
+				for(int i=0;i<searchresult.getData().size();i++)
+				{
+					searchresult.getData().get(i).put("read", (long) 1);
+
+				}
+//				searchresult.getData().clear();// .remove(position);
+				adapter.notifyDataSetChanged();				
+			}
+			default:
+				break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+
+	@Override
+	public boolean onTouch(View v, MotionEvent event)
+	{
+		switch (event.getAction())
+		{
+			case MotionEvent.ACTION_DOWN:
+				System.out.println("====>>>>>>>>>>>>>>ACTION_DOWN"
+						+ MotionEvent.ACTION_DOWN);
+				// 手指按下,计算焦点位于ListView的那个条目
+				pointX = (int) event.getX();
+				pointY = (int) event.getY();
+				// 备注1
+				position = getListView().pointToPosition(pointX, pointY);
+				if (curDel_btn != null)
+				{
+					curDel_btn.setVisibility(View.GONE);
+				}
+				break;
+			case MotionEvent.ACTION_MOVE:
+
+				break;
+			case MotionEvent.ACTION_UP:
+				System.out.println("====>>>>>>>>>>>>>>ACTION_UP"
+						+ MotionEvent.ACTION_UP);
+				endX = (int) event.getX();
+				endY = (int) event.getY();
+				newpos = getListView().pointToPosition(endX, endY);
+				// 原本想着加上这个条件(newpos==position)是不是更精确些,
+				// 经过实践发现,其实我们在滑动listView的列表的时候有时候更渴望有滑动就ok
+				if (Math.abs(endX - pointX) > 100 && newpos == position
+						&& Math.abs(endY - pointY) < 100)
+				{
+					// 获取到ListView第一个可见条目的position
+					int firstVisiblePosition = getListView()
+							.getFirstVisiblePosition();
+
+					// --------------备注2
+					View view = getListView().getChildAt(
+							position - firstVisiblePosition);
+					Button delbtn = (Button) view.findViewById(R.id.btn_del);
+					delbtn.setVisibility(View.VISIBLE);
+					curDel_btn = delbtn;
+					delbtn.setOnClickListener(new View.OnClickListener()
+					{
+
+						@Override
+						public void onClick(View v)
+						{
+							// TODO Auto-generated method stub
+
+							SQLiteDatabase db = dbUtil.OpenDB(
+									MessageActivity.this, null, false);
+							db.execSQL("delete from push_message where _id="
+									+ (Long) searchresult.getData()
+											.get(position).get("_id"));
+							Log.d("sql delete" + position,
+									"delete from push_message where _id="
+											+ (Long) searchresult.getData()
+													.get(position).get("_id"));
+
+							dbUtil.CloseDB(db);
+							searchresult.getData().remove(position);
+							adapter.notifyDataSetChanged();
+						}
+					});
+
+				}
+				break;
+
+			default:
+				break;
+		}
+		return false;
+	}
+
+	@Override
+	protected void onListItemClick(ListView l, View v, int position, long id)
+	{
+		SQLiteDatabase db = dbUtil.OpenDB(MessageActivity.this, null, false);
+		db.execSQL("update push_message set read = 1 where _id="
+				+ (Long) searchresult.getData().get(position).get("_id"));
+		searchresult.getData().get(position).put("read", (long) 1);// .get("_id")
+		dbUtil.CloseDB(db);
+		adapter.notifyDataSetChanged();
+		super.onListItemClick(l, v, position, id);
+
+		// Log.i("FragmentList", "Item clicked: " + id);
+		Intent intent = new Intent();
+		intent.putExtra("s_id", (String) searchresult.getData().get(position)
+				.get("s_id"));
+		intent.putExtra("e_id", (String) searchresult.getData().get(position)
+				.get("e_id"));
+		intent.putExtra("msgcount", (Long) searchresult.getData().get(position)
+				.get("msgcount"));
+
+		intent.setClass(this, MessageDetailActivity.class);
+		startActivity(intent);
+	}
+
+	@Override
+	public void onCreate(Bundle savedInstanceState)
+	{
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.message_list);
+		adapter = new MessageAdapter(searchresult, this);
+
+		getListView().setOnTouchListener(this);
+		setListAdapter(adapter);
+
+	}
+
+	private class SearchResult
+	{
+		List<Map<String, Object>>	datalist	= new ArrayList<Map<String, Object>>();
+
+		public int get_count()
+		{
+			return datalist.size();
+		}
+
+		public void add_records(Cursor c)
+		{
+			while (c.moveToNext())
+			{
+				long _id = c.getInt(0);
+				String h_time = c.getString(1);
+				long create_time = c.getLong(2);
+				long read = c.getLong(3);
+				String s_id = c.getString(4);
+				String e_id = c.getString(5);
+				long msgcount = c.getInt(6);
+				Map<String, Object> map = new HashMap<String, Object>();
+				map.put("_id", _id);
+				map.put("h_time", h_time);
+				map.put("create_time", create_time);
+				map.put("read", read);
+				map.put("s_id", s_id);
+				map.put("e_id", e_id);
+				map.put("msgcount", msgcount);
+
+				datalist.add(map);
+			}
+
+		}
+
+		public List<Map<String, Object>> getData()
+		{
+
+			return datalist;
+		}
+	}
+
+	private class MessageAdapter extends BaseAdapter
+	{
+		private LayoutInflater	mInflater;	// 动态布局映射
+											// private SearchResult result;
+
+		// private Context context;
+		// private int i = 0;
+		public MessageAdapter(SearchResult result, Context context)
+		{
+			// this.result = result;
+			this.mInflater = LayoutInflater.from(context);
+			SQLiteDatabase db = dbUtil
+					.OpenDB(MessageActivity.this, null, false);
+			Cursor cursor = db.query("push_message",
+					new String[] { "_id", "h_time", "create_time", "read",
+							"s_id", "e_id", "msgcount" }, "user='"
+							+ ApexTrackingApplication.get_user() + "'", null,
+					null, null, "_id desc", null);
+
+			result.add_records(cursor);
+			dbUtil.CloseCursor(cursor);
+			dbUtil.CloseDB(db);
+			// this.result = result;
+			// // this.context = context;
+			// this.mInflater = LayoutInflater.from(context);
+		}
+
+		@Override
+		public View getView(int position, View convertView, ViewGroup parent)
+		{
+			// TODO Auto-generated method stub
+			convertView = mInflater.inflate(R.layout.message_list_item, null);// 根据布局文件实例化view
+
+			TextView message = (TextView) convertView
+					.findViewById(R.id.tv_message);// 找某个控件
+
+			message.setText(getString(R.string.str_notification_text));// 给该控件设置数据(数据从集合类中来)
+			TextView time = (TextView) convertView.findViewById(R.id.tv_time);
+			time.setText(DateFormat.format(
+					getString(R.string.time_format),
+					(Long) searchresult.getData().get(position)
+							.get("create_time")));
+			if ((Long) searchresult.getData().get(position).get("read") == 0)
+			{
+				message.getPaint().setFakeBoldText(true);
+				time.getPaint().setFakeBoldText(true);
+				convertView.setBackgroundColor(Color.LTGRAY);
+			}
+			else
+			{
+				message.getPaint().setFakeBoldText(false);
+				time.getPaint().setFakeBoldText(false);
+				convertView.setBackgroundColor(Color.WHITE);
+			}
+
+			return convertView;
+		}
+
+		@Override
+		public int getCount()
+		{
+			return searchresult.get_count();
+		}
+
+		@Override
+		public Object getItem(int position)
+		{
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		@Override
+		public long getItemId(int position)
+		{
+			// TODO Auto-generated method stub
+			return 0;
+		}
+	}
+
+}

+ 424 - 0
Apex Mobile/app/src/main/java/com/usai/apex/MessageDetailActivity.java

@@ -0,0 +1,424 @@
+package com.usai.apex;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.util.Network;
+
+import android.app.ListActivity;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AutoCompleteTextView;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+import android.widget.RadioGroup;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class MessageDetailActivity extends ListActivity
+{
+	long				msgcount		= 0;
+	String				e_id			= "";
+	String				s_id			= "";
+	int					limit			= 10;
+	int					offset			= 0;
+	private SearchTask	m_task			= null;
+	SearchResult		searchresult	= new SearchResult();
+	BaseAdapter			adapter			= null;
+	View				view_page_footer;
+
+	// String module_name = "";
+
+	public void requestdata()
+	{
+
+		if (m_task != null)
+		{
+			return;
+		}
+		// mStatusMessageView.setText(R.string.str_Loading);
+		// showProgress(true);
+		m_task = new SearchTask();
+
+		TextView text_page = (TextView) view_page_footer
+				.findViewById(R.id.text_page);
+		text_page.setText("Loading...");
+		text_page.setEnabled(false);
+		m_task.execute();
+
+	}
+
+	@Override
+	protected void onListItemClick(ListView l, View v, int position, long id)
+	{
+		super.onListItemClick(l, v, position, id);
+
+		Intent intent = new Intent();
+		intent.setClass(this, DetailActivity.class);
+
+		intent.putExtra("action0", "Tracking");
+		intent.putExtra("function_name", "Cargo Tracking");
+
+		intent.putExtra("cargo_criterion", searchresult.getData().get(position)
+				.get("url").toString());
+		intent.putExtra("actions_count", 1);
+		intent.putExtra("_id", "dumb");
+//		String h_field;
+		intent.putExtra("criterion_type", 1);
+//		h_field = "container_no";
+
+		startActivity(intent);
+
+	}
+
+	@Override
+	public void onDestroy()
+	{
+		if (m_task != null)
+			m_task.cancel(false);
+		super.onDestroy();
+	}
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+
+		// setTitle("Booking Result");
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.message_list);
+		adapter = new AnnouncementAdapter(searchresult, this);
+
+		s_id = getIntent().getStringExtra("s_id");
+		e_id = getIntent().getStringExtra("e_id");
+		msgcount = getIntent().getLongExtra("msgcount", 0);
+		view_page_footer = LayoutInflater.from(this).inflate(
+				R.layout.view_page_footer, null);
+		getListView().addFooterView(view_page_footer);// 添加底部视图
+		TextView text_page = (TextView) view_page_footer
+				.findViewById(R.id.text_page);
+		text_page.setOnClickListener(new View.OnClickListener()
+		{
+			// 点击按钮 追加数据 并通知适配器
+			@Override
+			public void onClick(View v)
+			{
+				// TODO Auto-generated method stub
+				// TextView tv = (TextView) v;
+				// tv.setText("Loading...");
+				offset += 10;
+				requestdata();
+				// tv.setText("下一页");
+				// adapter.notifyDataSetChanged();
+			}
+		});
+
+		setListAdapter(adapter);
+		// this.getListView().setBackgroundColor(Color.WHITE);
+		requestdata();
+
+	}
+
+	class SearchTask extends AsyncTask<Void, Void, Boolean>
+	{
+		int		errorcode;
+		boolean	bfinish	= false;
+
+		@Override
+		protected Boolean doInBackground(Void... params)
+		{
+			Log.d("SearchTask", "doInBackground");
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+			String jstr = Network.get_push(e_id, s_id, limit, offset);
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			JSONObject jsobj;
+			//
+			// array = new JSONArray(json);
+			try
+			{
+				jsobj = new JSONObject(jstr);
+				// if (searchresult.get_fieldscount() == 0)
+				// {
+				// JSONObject objfields = jsobj.getJSONObject("fields");
+				// if (objfields != null)
+				// searchresult.init_fields(objfields.toString());
+				// }
+				int count = jsobj.getInt("total");
+				if (msgcount - offset <= limit)
+					bfinish = true;
+				JSONObject objrecords = jsobj.getJSONObject("records");
+				if (objrecords != null)
+					searchresult.add_records(objrecords.toString(), count);
+				errorcode = Network.RESULT_TRUE;
+
+				return true;
+
+			}
+			catch (JSONException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			errorcode = Network.RESULT_NET_ERROR;
+			return false;
+		}
+
+		@Override
+		protected void onPostExecute(Boolean success)
+		{
+			Log.d("onPostExecute", "entry");
+			m_task = null;
+			// showProgress(false);
+
+			switch (errorcode)
+			{
+				case Network.RESULT_NET_NOTAVAILABLE:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_NET_ERROR:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_resulterror),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+
+				default:
+					break;
+			}
+
+			if (success)
+			{
+
+				if (bfinish)
+				{
+					// getListView().removeFooterView(view_page_footer);
+					// Toast.makeText(AnnouncementActivity.this, "Load all!",
+					// Toast.LENGTH_LONG).show();
+
+					TextView tv = (TextView) view_page_footer
+							.findViewById(R.id.text_page);
+					tv.setText("No more items");
+					tv.setEnabled(false);
+				}
+				else
+				{
+					TextView tv = (TextView) view_page_footer
+							.findViewById(R.id.text_page);
+					tv.setText("More...");
+					tv.setEnabled(true);
+				}
+				adapter.notifyDataSetChanged();
+				// getListAdapter().notifyDataSetChanged;
+				// BaseAdapter mJson = null;
+				// mJson.notifyDataSetChanged();
+			}
+
+			super.onPostExecute(success);
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			m_task = null;
+			// showProgress(false);
+		}
+	}
+
+	private class SearchResult
+	{
+		List<Map<String, Object>>	datalist	= new ArrayList<Map<String, Object>>();
+
+		public int get_count()
+		{
+			return datalist.size();
+		}
+
+		public void add_records(String source, int count)
+		{
+			JSONObject objrecords;
+			try
+			{
+				objrecords = new JSONObject(source);
+
+				for (int i = 0; i < count; i++)
+				{
+					// offset++;
+					JSONObject objrec = objrecords.getJSONObject("record" + i);
+					String title = objrec.getString("title");
+					// String content = objrec.getString("content");
+					// String image = objrec.getString("image");
+					// String id = objrec.getString("id");
+					String url = objrec.getString("url");
+					// lastid = id;
+					Map<String, Object> map = new HashMap<String, Object>();
+					map.put("title", title);
+					// map.put("content", content);
+					// map.put("image", image);
+					// map.put("id", id);
+					map.put("url", url);
+					datalist.add(map);
+
+					// Iterator<?> it = rec.keys();
+					// HashMap<String, String> record = new HashMap<String,
+					// String>();
+					// while (it.hasNext()) // loop for each function
+					// {
+					// String field_name = (String) it.next();
+					// String val = rec.getString(field_name)
+					// .replace("\n", "");
+					// record.put(field_name, val);
+					// }
+					// records.add(record);
+
+				}
+			}
+			catch (JSONException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+
+		}
+
+		public List<Map<String, Object>> getData()
+		{
+
+			return datalist;
+		}
+	}
+
+	private class AnnouncementAdapter extends BaseAdapter
+	{
+		private LayoutInflater	mInflater;	// 动态布局映射
+		private SearchResult	result;
+
+		// private Context context;
+		// private int i = 0;
+		public AnnouncementAdapter(SearchResult result, Context context)
+		{
+			this.result = result;
+			// this.context = context;
+			this.mInflater = LayoutInflater.from(context);
+		}
+
+		@Override
+		public int getCount()
+		{
+			// TODO Auto-generated method stub
+			return result.get_count();
+		}
+
+		@Override
+		public Object getItem(int position)
+		{
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		@Override
+		public long getItemId(int position)
+		{
+			// TODO Auto-generated method stub
+			return 0;
+		}
+
+		@Override
+		public View getView(int position, View convertView, ViewGroup parent)
+		{
+			// TODO Auto-generated method stub
+			convertView = mInflater.inflate(R.layout.message_detail_item, null);// 根据布局文件实例化view
+
+			TextView title = (TextView) convertView.findViewById(R.id.tv_title);// 找某个控件
+			title.setText(Html.fromHtml(result.getData().get(position)
+					.get("title").toString()));
+			// title.setMovementMethod(LinkMovementMethod.getInstance());
+			// title.setText(result.getData().get(position).get("title")
+			// .toString());// 给该控件设置数据(数据从集合类中来)
+			// TextView content = (TextView) convertView
+			// .findViewById(R.id.tv_content);
+			// content.setText(result.getData().get(position).get("content")
+			// .toString());
+			// if
+			// (result.getData().get(position).get("image").toString().length()
+			// > 0)
+			// {
+			// byte[] gzipBuff = Base64.decode(result.getData().get(position)
+			// .get("image").toString(), 0);
+			//
+			// ByteArrayInputStream memstream = new ByteArrayInputStream(
+			// gzipBuff, 0, gzipBuff.length);
+			//
+			// ByteArrayOutputStream baos = new ByteArrayOutputStream(
+			// gzipBuff.length);
+			// ImageView iv_thumb = (ImageView) convertView
+			// .findViewById(R.id.iv_thumb);
+			// try
+			// {
+			// baos.write(gzipBuff);
+			//
+			// Bitmap bmp = BitmapFactory.decodeStream(memstream);
+			//
+			// // ImageView image = new ImageView(this);
+			//
+			// iv_thumb.setImageBitmap(bmp);
+			// }
+			// catch (IOException e)
+			// {
+			// // TODO Auto-generated catch block
+			// e.printStackTrace();
+			// }
+			// }
+			// img.setBackgroundResource((Integer)jObject.get("img"));
+
+			return convertView;
+		}
+	}
+
+}

+ 870 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ResultActivity.java

@@ -0,0 +1,870 @@
+package com.usai.apex;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.util.Network;
+import com.usai.util.dbUtil;
+
+import android.net.Uri;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DownloadManager;
+import android.app.AlertDialog.Builder;
+import android.app.DownloadManager.Request;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.text.Html;
+import android.text.style.URLSpan;
+import android.util.Log;
+import android.util.SparseArray;
+import android.view.ContextMenu;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ContextMenu.ContextMenuInfo;
+import android.view.View.OnClickListener;
+import android.view.View.OnCreateContextMenuListener;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.TableLayout;
+import android.widget.TableRow;
+import android.widget.TextView;
+import android.widget.Toast;
+
+public class ResultActivity extends Activity
+{
+
+	private static final int	REQUEST_LOGINACTIVITY	= 1;
+	String						user					= null;
+	String						password				= null;
+	String						function_name			= null;
+	private SearchTask			m_task					= null;
+
+	final int					OFFSET					= 5;
+
+	int							sel						= -1;
+
+	Bundle						searchParms				= null;
+	SearchResult				searchresult			= new SearchResult();
+
+	SparseArray<String>			showfieldmap			= new SparseArray<String>();
+	// HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
+	private TextView			mStatusMessageView;
+	// private View mSearchFormView;
+	private View				footview;
+	private View				mStatusView;
+	int							actioncount				= 0;
+
+	// private class resultAdapter extends SimpleAdapter
+	// {
+	//
+	//
+	// }
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		user = ApexTrackingApplication.get_user();
+		password = ApexTrackingApplication.get_pass();
+		function_name = getIntent().getStringExtra("function_name");
+		if (function_name.equals("Ocean Booking"))
+			setTitle("Booking Result");
+		else if (function_name.equals("Ocean B/L info."))
+			setTitle("B/L info. Result");
+		else if (function_name.equals("Container detail"))
+			setTitle("Container Result");
+		else if (function_name.equals("Download Document"))
+			setTitle("Document Result");
+
+		searchParms = getIntent().getBundleExtra("searchParms");
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_result);
+
+		SQLiteDatabase db = dbUtil.OpenDB(ResultActivity.this, null, false);
+		Cursor cursor = db
+				.query("actions_info", new String[] { "count(*)" },
+						"function_name='" + function_name + "' and user='"
+								+ user + "'", null, null, null, "priority",
+						null);
+		if (cursor.moveToNext())
+		{
+			actioncount = cursor.getInt(0);
+		}
+
+		dbUtil.CloseCursor(cursor);
+		dbUtil.CloseDB(db);
+
+		footview = findViewById(R.id.foot);
+		// mSearchFormView = findViewById(R.id.search_form);
+		Button btnnext = (Button) findViewById(R.id.btn_next);
+		btnnext.setOnClickListener(new View.OnClickListener()
+		{
+
+			@Override
+			public void onClick(View v)
+			{
+				// TextView tv_head = (TextView) findViewById(R.id.tv_head);
+
+				// searchresult.set_direction(1);
+				if (searchresult.get_totalcount() == -1)
+					requestdata(true);
+				else
+				{
+					// if (searchresult.get_direction() == -1)
+					searchresult.set_offset(searchresult.get_offset() + OFFSET);
+					requestdata(false);
+				}
+
+			}
+		});
+
+		Button btnpre = (Button) findViewById(R.id.btn_pre);
+		btnpre.setOnClickListener(new View.OnClickListener()
+		{
+
+			@Override
+			public void onClick(View v)
+			{
+				// TextView tv_head = (TextView) findViewById(R.id.tv_head);
+				// searchresult.set_direction(-1);
+				if (searchresult.get_totalcount() == -1)
+					requestdata(true);
+				else
+				{
+					searchresult.set_offset(searchresult.get_offset() - OFFSET);
+					requestdata(false);
+				}
+
+			}
+		});
+		mStatusView = findViewById(R.id.status);
+		mStatusMessageView = (TextView) findViewById(R.id.status_message);
+		LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
+		Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
+		btn_refresh.setOnClickListener(new View.OnClickListener()
+		{
+
+			@Override
+			public void onClick(View v)
+			{
+				LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.INVISIBLE);
+				if (searchresult.get_totalcount() == -1)
+					requestdata(true);
+				else
+					requestdata(false);
+
+			}
+		});
+
+		SharedPreferences RunOnce = getSharedPreferences("Apex", 0);
+
+		String vername;
+		try
+		{
+			vername = getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
+			boolean bFirstRun = RunOnce.getBoolean("FirstRun" + vername
+					+ "_result", true);
+			if (bFirstRun)
+			{
+				SharedPreferences.Editor editor = RunOnce.edit();
+				editor.putBoolean("FirstRun" + vername + "_result", false);
+				// Don't forget to commit your edits!!!
+				editor.commit();
+				Intent intent = new Intent();
+				intent.setClass(this, HelpActivity.class);
+				intent.putExtra("caller", "result");
+				startActivity(intent);
+
+			}
+		}
+		catch (NameNotFoundException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		initTableHeader();
+		if (savedInstanceState != null)
+		{
+			searchresult = (SearchResult) savedInstanceState
+					.getSerializable("searchresult");
+			if (searchresult.get_totalcount() == -1)
+				requestdata(true);
+			else
+				initTable();
+		}
+		else
+			requestdata(true);
+
+	}
+
+	@Override
+	protected void onDestroy()
+	{
+		if (m_task != null)
+			m_task.cancel(false);
+		super.onDestroy();
+	}
+
+	private void initTable()
+	{
+		// int loadcount = searchresult.get_count();
+		int totalcount = searchresult.get_totalcount();
+		TextView tv_head = (TextView) findViewById(R.id.head);
+		if (totalcount == 0)
+		{
+			tv_head.setText(R.string.str_0);
+
+			return;
+		}
+		else if (searchresult.get_totalcount() > 2000)
+		{
+			tv_head.setText(R.string.str_2000);
+		}
+		else
+			tv_head.setText(/*
+							 * loadcount + "/" + //
+							 */searchresult.get_totalcount()
+					+ getText(R.string.str_records).toString());
+		TableLayout tl = (TableLayout) findViewById(R.id.result_table);
+
+		tl.removeViews(1, tl.getChildCount() - 1);
+		// int newcount = loadcount - showcount + 1;// +1 header row
+		for (int i = 0; i < searchresult.get_recordscount(); i++)
+		{
+
+			TableRow recordRow = new TableRow(ResultActivity.this);
+			recordRow.setOnLongClickListener(new View.OnLongClickListener()
+			{
+
+				@Override
+				public boolean onLongClick(View v)
+				{
+					// TODO Auto-generated method stub
+					// v.setBackgroundColor(Color.GRAY);
+					// v.showContextMenu();
+					// return true;
+					TableRow tr = (TableRow) v;
+					TextView tvno = (TextView) tr.getChildAt(0);
+					sel = (Integer.parseInt(tvno.getText().toString())-1) % 5 ;
+					registerForContextMenu(v);
+					openContextMenu(v);
+					unregisterForContextMenu(v);
+					return true;
+				}
+			});
+
+			// registerForContextMenu(recordRow);
+			// recordRow.setClickable(true);
+			// registerForContextMenu(recordRow);
+			// recordRow.setOnCreateContextMenuListener(m_tableMenu);
+			// recordRow.SETSE
+
+			HashMap<String, String> record = searchresult.get_record(i);
+			TextView field = new TextView(ResultActivity.this);
+			field.setBackgroundResource(R.drawable.tableitem);
+			field.setText(searchresult.get_offset() + i + 1 + "");
+			Log.d("offset=" + searchresult.get_offset(), "");
+			field.setGravity(Gravity.CENTER);
+			field.setPadding(10, 5, 10, 5);
+			field.setTextSize(20);
+			recordRow.addView(field);
+			for (int j = 0; j < showfieldmap.size(); j++)
+			{
+				TextView field1 = new TextView(ResultActivity.this);
+				// Log.d("onPostExecute", showfieldmap.get(j));
+				String str = record.get(showfieldmap.get(j));
+				field1.setBackgroundResource(R.drawable.tableitem);
+				if (str.toLowerCase().trim().equals("null"))
+					str = "";
+
+				// field1.setBackgroundColor(0xFFFFFFFF);
+
+				field1.setText(Html.fromHtml(str));
+
+				if (actioncount == 0)
+					field1.setOnClickListener(new OnClickListener()
+					{
+
+						@Override
+						public void onClick(View v)
+						{
+							// if (true)
+							// return;
+							URLSpan span[] = ((TextView) v).getUrls();
+							if (span.length < 1)
+								return;
+							span[0].getURL();
+							Log.d("Text", span[0].getURL());
+							
+							TextView tv = (TextView)v;
+
+							final DownloadManager downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
+
+							Uri uri = Uri.parse(span[0].getURL());
+							final Request request = new Request(uri);
+
+							// 设置允许使用的网络类型,这里是移动网络和wifi都可以
+							request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_MOBILE
+									| DownloadManager.Request.NETWORK_WIFI);
+							
+							request.setDestinationInExternalPublicDir("Apex Mobile",tv.getText().toString()); 
+
+							// 禁止发出通知,既后台下载,如果要使用这一句必须声明一个权限:android.permission.DOWNLOAD_WITHOUT_NOTIFICATION
+							// request.setShowRunningNotification(false);
+
+							// 不显示下载界面
+							request.setVisibleInDownloadsUi(false);
+							request.setNotificationVisibility(Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
+
+							/*
+							 * 设置下载后文件存放的位置,如果sdcard不可用,那么设置这个将报错,
+							 * 因此最好不设置如果sdcard可用,下载后的文件 在/mnt/sdcard/Android/
+							 * data/packageName/files目录下面
+							 * ,如果sdcard不可用,设置了下面这个将报错,不设置,下载后的文件在/cache这个 目录下面
+							 */
+							// request.setDestinationInExternalFilesDir(this,
+							// null, "tar.apk");
+
+							AlertDialog.Builder builder = new Builder(
+									ResultActivity.this);
+							builder.setMessage(getString(R.string.str_downloadmessage));
+
+							builder.setTitle(getString(R.string.str_confirmdownload));
+
+							builder.setPositiveButton(
+									getString(R.string.str_download),
+									new Dialog.OnClickListener()
+									{
+
+										@Override
+										public void onClick(
+												DialogInterface dialog,
+												int which)
+										{
+											downloadManager.enqueue(request);
+											dialog.dismiss();
+
+										}
+									});
+
+							builder.setNegativeButton(
+									getString(R.string.str_cancel),
+									new Dialog.OnClickListener()
+									{
+
+										@Override
+										public void onClick(
+												DialogInterface dialog,
+												int which)
+										{
+											dialog.dismiss();
+										}
+									});
+
+							builder.create().show();
+
+						}
+
+					});
+				// field1.setText(str);
+				field1.setGravity(Gravity.LEFT);
+				field1.setPadding(10, 5, 10, 5);
+				field1.setTextSize(20);
+				// field.setTextAppearance(ResultActivity.this,
+				// android.R.attr.textAppearanceMedium);
+				recordRow.addView(field1);
+			}
+			tl.addView(recordRow);
+		}
+
+		Button btnnext = (Button) findViewById(R.id.btn_next);
+
+		Button btnpre = (Button) findViewById(R.id.btn_pre);
+		if (searchresult.get_offset() == 0)
+			btnpre.setEnabled(false);
+		else
+		{
+			btnpre.setEnabled(true);
+		}
+		if ((searchresult.get_totalcount() - searchresult.get_offset() <= OFFSET)
+				|| (searchresult.get_totalcount() == 0))
+			btnnext.setEnabled(false);
+		else
+			btnnext.setEnabled(true);
+	}
+
+	private OnCreateContextMenuListener	m_tableMenu	= new OnCreateContextMenuListener()
+													{
+
+														@Override
+														public void onCreateContextMenu(
+																ContextMenu contextmenu,
+																View view,
+																ContextMenuInfo contextmenuinfo)
+														{
+
+															contextmenu
+																	.add(Menu.NONE,
+																			0,
+																			0,
+																			getString(R.string.str_detail));
+
+														}
+
+													};
+
+	@Override
+	public boolean onContextItemSelected(MenuItem item)
+	{
+		// menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
+		// Log.d("table row select", sel+ "");
+
+		Intent intent = new Intent();
+		intent.setClass(this, DetailActivity.class);
+
+		SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
+		Cursor cursor = db.query("actions_info",
+				new String[] { "name", "_id" }, "function_name='"
+						+ function_name + "' and user='" + user + "'", null,
+				null, null, "priority", null);
+		int i = 0;
+		while (cursor.moveToNext())
+		{
+			String name = cursor.getString(0);
+			Log.d("actionname", name);
+			intent.putExtra("action" + i, name);
+			i++;
+		}
+		intent.putExtra("function_name", function_name);
+		intent.putExtra("actions_count", i);
+		intent.putExtra("_id", searchresult.get_record(sel).get("_id")
+				.toString());
+		dbUtil.CloseCursor(cursor);
+		dbUtil.CloseDB(db);
+
+		startActivity(intent);
+
+		return super.onContextItemSelected(item);
+	}
+
+	// @Override
+	// public void onCreateContextMenu(ContextMenu menu, View v,
+	// ContextMenuInfo menuInfo)
+	// {
+	// // // TODO Auto-generated method stub
+	// menu.add(Menu.NONE, 0, 0, "Detail");
+	// // // contextmenu.add(Menu.NONE, 1, 1, "�༭");
+	// super.onCreateContextMenu(menu, v, menuInfo);
+	// }
+
+	void initTableHeader()
+	{
+
+		TableLayout tl = (TableLayout) findViewById(R.id.result_table);
+		tl.setFocusable(true);
+		tl.setOnCreateContextMenuListener(m_tableMenu);
+		SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
+		Cursor cursor = db.query("fields_info", new String[] { "aname", "name",
+				"_id" }, "function_name='" + function_name + "' and user='"
+				+ user + "' and behavior=" + Network.BEHAVIOR_RESULT
+				+ " and show = 1", null, null, null, "priority , aname", null);
+		TableRow headerRow = (TableRow) findViewById(R.id.tr_header);
+		int pos = 0;
+		showfieldmap.clear();
+		headerRow.removeAllViews();
+		ArrayList<HashMap<String, String>> gridheader = new ArrayList<HashMap<String, String>>();
+		HashMap<String, String> map = new HashMap<String, String>();
+		map.put("key", "no.");
+		gridheader.add(map);
+		Button btn = new Button(this);
+		btn.setBackgroundResource(R.drawable.tablehead);
+		btn.setPadding(0, 0, 0, 0);
+		btn.setText("No.");
+		headerRow.addView(btn);
+		while (cursor.moveToNext())
+		{
+			String aname = cursor.getString(0);
+			Button btn1 = new Button(this);
+			btn1.setBackgroundResource(R.drawable.tablehead);
+			btn1.setText(aname);
+			headerRow.addView(btn1);
+			showfieldmap.put(pos, cursor.getString(1));
+
+			map.put("key", "header");
+			gridheader.add(map);
+			pos++;
+		}
+		dbUtil.CloseCursor(cursor);
+		dbUtil.CloseDB(db);
+
+		// SimpleAdapter adapter = new SimpleAdapter(this,
+		// gridheader,// �����Դ
+		// R.layout.result_item,//XMLʵ��
+		// new String[] { "key" }, // ��̬������ImageItem��Ӧ������
+		// new int[] { R.id.tv_value });
+		//
+		// GridView gridview = (GridView) findViewById(R.id.grid_result);
+		// gridview.setNumColumns(2);
+		// gridview.setAdapter(adapter);
+
+	}
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.result, menu);
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		Intent intent = new Intent();
+		switch (item.getItemId())
+		{
+			case R.id.action_custom_fields:
+
+				intent.setClass(this, CustomizeFieldsActivity.class);
+				intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+				intent.putExtra("function_name", function_name);
+				intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
+				startActivity(intent);
+				break;
+			case R.id.action_help:
+				// Intent intent = new Intent();
+				intent.setClass(this, HelpActivity.class);
+				intent.putExtra("caller", "result");
+				// // intent.putExtra("password", password);
+				// intent.putExtra("function_name", function_name);
+				// intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+				startActivity(intent);
+				break;
+			case R.id.action_save_search:
+				// LayoutInflater factory = LayoutInflater.from(this);
+				// final View textEntryView =
+				// factory.inflate(R.layout.alert_dialog_text_entry, null);
+				final View edit = new EditText(this);
+				new AlertDialog.Builder(this)
+						.setIconAttribute(android.R.attr.alertDialogIcon)
+						.setTitle(R.string.str_createname)
+						.setView(edit)
+						.setPositiveButton(android.R.string.ok,
+								new DialogInterface.OnClickListener()
+								{
+									public void onClick(DialogInterface dialog,
+											int whichButton)
+									{
+										String name = ((EditText) edit)
+												.getText().toString();
+										String param = getIntent().toUri(0);
+
+										JSONObject obj = new JSONObject();
+										Set<String> keys = searchParms.keySet();
+										for (String key : keys)
+										{
+
+											
+											try
+											{
+												obj.put(key, searchParms.get(key).toString());
+
+											}
+											catch (JSONException e)
+											{
+												// TODO Auto-generated catch block
+												e.printStackTrace();
+											}
+
+										}
+										obj.toString();
+
+										SQLiteDatabase db = dbUtil.OpenDB(
+												ApexTrackingApplication.get_instance(), null, true);
+										db.execSQL("insert into history(params,name,criterion,module_name,user,create_time) values('"
+
+												+ param
+												+ "','"
+												+ name
+												+ "','"
+												+ obj.toString()
+												+ "','"
+												+ function_name
+												+ "','"
+												+ ApexTrackingApplication.get_user()
+												+ "',"
+												+ System.currentTimeMillis() + ")");
+										dbUtil.CloseDB(db);
+
+										/* User clicked OK so do some stuff */
+									}
+								})
+						.setNegativeButton(android.R.string.cancel,
+								new DialogInterface.OnClickListener()
+								{
+									public void onClick(DialogInterface dialog,
+											int whichButton)
+									{
+
+										/* User clicked cancel so do some stuff */
+									}
+								}).create().show();
+				break;
+			default:
+				break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+
+	public void requestdata(boolean requestcount)
+	{
+
+		if (m_task != null)
+		{
+			return;
+		}
+		mStatusMessageView.setText(R.string.str_Loading);
+		showProgress(true);
+		m_task = new SearchTask();
+		m_task.execute(requestcount);
+
+	}
+
+	private void showProgress(final boolean show)
+	{
+		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
+		// for very easy animations. If available, use these APIs to fade-in
+		// the progress spinner.
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
+		{
+			int shortAnimTime = getResources().getInteger(
+					android.R.integer.config_shortAnimTime);
+
+			mStatusView.setVisibility(View.VISIBLE);
+			mStatusView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 1 : 0)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							mStatusView.setVisibility(show ? View.VISIBLE
+									: View.INVISIBLE);
+						}
+					});
+
+			footview.setVisibility(View.VISIBLE);
+			footview.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							footview.setVisibility(show ? View.INVISIBLE
+									: View.VISIBLE);
+						}
+					});
+			// mSearchFormView.setVisibility(View.VISIBLE);
+			// mSearchFormView.animate().setDuration(shortAnimTime)
+			// .alpha(show ? 0 : 1)
+			// .setListener(new AnimatorListenerAdapter()
+			// {
+			// @Override
+			// public void onAnimationEnd(Animator animation)
+			// {
+			// mSearchFormView.setVisibility(show ? View.INVISIBLE
+			// : View.VISIBLE);
+			// }
+			// });
+		}
+		else
+		{
+			// The ViewPropertyAnimator APIs are not available, so simply show
+			// and hide the relevant UI components.
+			mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
+			footview.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
+			// mSearchFormView.setVisibility(show ? View.INVISIBLE :
+			// View.VISIBLE);
+		}
+	}
+
+	public class SearchTask extends AsyncTask<Boolean, Void, Boolean>
+	{
+		// int err_code = ERR_CODE_NONE;
+		int	errorcode;
+
+		@Override
+		protected Boolean doInBackground(Boolean... params)
+		{
+
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+
+			if (params[0])
+			{
+				int ret = Network.get_recordcount(searchParms);
+				if (ret >= 0)
+				{
+					searchresult.put_totalcount(ret);
+					if (ret == 0)
+						return true;
+				}
+				else
+				{
+					errorcode = ret;
+					return false;
+				}
+			}
+
+			// if (searchresult.get_direction() == -1)
+			// searchresult.set_offset(searchresult.get_offset() - 20);
+			searchParms.putString("offset", searchresult.get_offset() + "");
+
+			String jstr = Network.get_records(user, password, searchParms);
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			JSONObject jsobj;
+			//
+			// array = new JSONArray(json);
+			try
+			{
+				jsobj = new JSONObject(jstr);
+				// if (searchresult.get_fieldscount() == 0)
+				// {
+				// JSONObject objfields = jsobj.getJSONObject("fields");
+				// if (objfields != null)
+				// searchresult.init_fields(objfields.toString());
+				// }
+				JSONObject objrecords = jsobj.getJSONObject("records");
+				if (objrecords != null)
+					searchresult.add_records(objrecords.toString());
+				errorcode = Network.RESULT_TRUE;
+
+				return true;
+
+			}
+			catch (JSONException e)
+			{
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			errorcode = Network.RESULT_NET_ERROR;
+			return false;
+
+		}
+
+		@Override
+		protected void onPostExecute(final Boolean success)
+		{
+			Log.d("onPostExecute", "entry");
+			m_task = null;
+			showProgress(false);
+			if (ApexTrackingApplication.get_authorization() == false)
+			{
+				LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.VISIBLE);
+				Toast toast = Toast.makeText(
+						ApexTrackingApplication.get_instance(),
+						getText(R.string.msg_net_passwordchangedremote),
+						Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				Intent i = new Intent();
+				i.setClass(ResultActivity.this, ApexActivity.class);
+				startActivityForResult(i, REQUEST_LOGINACTIVITY);
+				return;
+			}
+			switch (errorcode)
+			{
+				case Network.RESULT_NET_NOTAVAILABLE:
+				{
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_connection_none),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+				case Network.RESULT_NET_ERROR:
+				{
+
+					Toast toast = Toast.makeText(
+							ApexTrackingApplication.get_instance(),
+							getText(R.string.msg_net_resulterror) + ":"
+									+ errorcode, Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+
+					break;
+				}
+				case Network.RESULT_ERROR:
+				// case Network.RESULT_RESPONSE_NULL:
+				{
+					Toast toast = Toast.makeText(getApplicationContext(),
+							getText(R.string.msg_net_resulterror),
+							Toast.LENGTH_LONG);
+					toast.setGravity(Gravity.CENTER, 0, 0);
+					toast.show();
+					break;
+				}
+
+				default:
+					break;
+			}
+
+			if (success)
+			{
+
+				initTable();
+
+			}
+			else
+			{
+				LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.VISIBLE);
+			}
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			m_task = null;
+			showProgress(false);
+		}
+	}
+
+	@Override
+	protected void onSaveInstanceState(Bundle outState)
+	{
+		outState.putSerializable("searchresult", searchresult);
+		super.onSaveInstanceState(outState);
+	}
+
+}

+ 384 - 0
Apex Mobile/app/src/main/java/com/usai/apex/RetrievePasswordActivity.java

@@ -0,0 +1,384 @@
+package com.usai.apex;
+
+import com.usai.util.Network;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.annotation.TargetApi;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
+import android.content.Context;
+import android.os.AsyncTask;
+import android.os.Build;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * Activity which displays a login screen to the user, offering registration as
+ * well.
+ */
+public class RetrievePasswordActivity extends Activity
+{
+
+	/**
+	 * Keep track of the login task to ensure we can cancel it if requested.
+	 */
+	private UserLoginTask	mAuthTask	= null;
+
+	// Values for email and password at the time of the login attempt.
+	private String			m_sEmail;
+	private String			m_sUser;
+
+	// UI references.
+	private EditText		mEmailView;
+	private EditText		m_userView;
+	private View			mLoginFormView;
+	private View			mLoginStatusView;
+	private TextView		mLoginStatusMessageView;
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+
+		setContentView(R.layout.activity_retrieve_password);
+
+		// Set up the login form.
+		m_userView = (EditText) findViewById(R.id.user);
+		// m_sEmail = getIntent().getStringExtra(EXTRA_EMAIL);
+		mEmailView = (EditText) findViewById(R.id.email);
+		// mEmailView.setText(m_sEmail);
+
+		mEmailView
+				.setOnEditorActionListener(new TextView.OnEditorActionListener()
+				{
+					@Override
+					public boolean onEditorAction(TextView textView, int id,
+							KeyEvent keyEvent)
+					{
+						if (id == R.id.btn_ok
+								|| id == EditorInfo.IME_ACTION_DONE)
+						{
+
+							InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext()
+									.getSystemService(
+											Context.INPUT_METHOD_SERVICE);
+
+							// EditText editText =
+							// (EditText)findViewById(R.id.xxxx);
+							inputMethodManager.hideSoftInputFromWindow(
+									mEmailView.getWindowToken(), 0); // ����
+							retrivev();
+							return true;
+						}
+						return false;
+					}
+				});
+
+		mLoginFormView = findViewById(R.id.login_form);
+		mLoginStatusView = findViewById(R.id.login_status);
+		mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);
+
+		findViewById(R.id.btn_ok).setOnClickListener(new View.OnClickListener()
+		{
+			@Override
+			public void onClick(View view)
+			{
+				InputMethodManager inputMethodManager = (InputMethodManager) getApplicationContext()
+						.getSystemService(Context.INPUT_METHOD_SERVICE);
+
+				// EditText editText =
+				// (EditText)findViewById(R.id.xxxx);
+				inputMethodManager.hideSoftInputFromWindow(
+						mEmailView.getWindowToken(), 0); // ����
+				retrivev();
+			}
+		});
+		findViewById(R.id.btn_close).setOnClickListener(
+				new View.OnClickListener()
+				{
+					@Override
+					public void onClick(View view)
+					{
+						finish();
+					}
+				});
+	}
+
+	//
+	// @Override
+	// public boolean onCreateOptionsMenu(Menu menu) {
+	// super.onCreateOptionsMenu(menu);
+	// getMenuInflater().inflate(R.menu.retrieve_password, menu);
+	// return true;
+	// }
+
+	/**
+	 * Attempts to sign in or register the account specified by the login form.
+	 * If there are form errors (invalid email, missing fields, etc.), the
+	 * errors are presented and no actual login attempt is made.
+	 */
+	public void retrivev()
+	{
+		if (mAuthTask != null)
+		{
+			return;
+		}
+
+		// Reset errors.
+		mEmailView.setError(null);
+		m_userView.setError(null);
+
+		// Store values at the time of the login attempt.
+		m_sEmail = mEmailView.getText().toString();
+		m_sUser = m_userView.getText().toString();
+
+		boolean cancel = false;
+		View focusView = null;
+
+		// Check for a valid password.
+		if (TextUtils.isEmpty(m_sUser))
+		{
+			m_userView.setError(getString(R.string.error_field_required));
+			focusView = m_userView;
+			cancel = true;
+		}
+		// else if (m_sUser.length() < 4) {
+		// m_userView.setError(getString(R.string.error_invalid_password));
+		// focusView = m_userView;
+		// cancel = true;
+		// }
+
+		// Check for a valid email address.
+		if (TextUtils.isEmpty(m_sEmail))
+		{
+			mEmailView.setError(getString(R.string.error_field_required));
+			focusView = mEmailView;
+			cancel = true;
+		}
+		else if (!m_sEmail.contains("@"))
+		{
+			mEmailView.setError(getString(R.string.error_invalid_email));
+			focusView = mEmailView;
+			cancel = true;
+		}
+
+		if (cancel)
+		{
+			// There was an error; don't attempt login and focus the first
+			// form field with an error.
+			focusView.requestFocus();
+		}
+		else
+		{
+			// Show a progress spinner, and kick off a background task to
+			// perform the user login attempt.
+			mLoginStatusMessageView.setText(R.string.login_progress_signing_in);
+			showProgress(true);
+			mAuthTask = new UserLoginTask();
+			mAuthTask.execute((Void) null);
+		}
+	}
+
+	/**
+	 * Shows the progress UI and hides the login form.
+	 */
+	@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
+	private void showProgress(final boolean show)
+	{
+		// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
+		// for very easy animations. If available, use these APIs to fade-in
+		// the progress spinner.
+		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2)
+		{
+			int shortAnimTime = getResources().getInteger(
+					android.R.integer.config_shortAnimTime);
+
+			mLoginStatusView.setVisibility(View.VISIBLE);
+			mLoginStatusView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 1 : 0)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							mLoginStatusView.setVisibility(show ? View.VISIBLE
+									: View.GONE);
+						}
+					});
+
+			mLoginFormView.setVisibility(View.VISIBLE);
+			mLoginFormView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 0 : 1)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							mLoginFormView.setVisibility(show ? View.GONE
+									: View.VISIBLE);
+						}
+					});
+		}
+		else
+		{
+			// The ViewPropertyAnimator APIs are not available, so simply show
+			// and hide the relevant UI components.
+			mLoginStatusView.setVisibility(show ? View.VISIBLE : View.GONE);
+			mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
+		}
+	}
+
+	/**
+	 * Represents an asynchronous login/registration task used to authenticate
+	 * the user.
+	 */
+	public class UserLoginTask extends AsyncTask<Void, Void, Boolean>
+	{
+		int	errorcode;
+
+		@Override
+		protected Boolean doInBackground(Void... params)
+		{
+			errorcode = Network.retrieve_pass(m_sUser, m_sEmail);
+			if (errorcode == Network.RESULT_TRUE)
+				return true;
+			else
+			{
+				return false;
+			}
+
+		}
+
+		@Override
+		protected void onPostExecute(final Boolean success)
+		{
+			Log.d("onPostExecute", "entry");
+			mAuthTask = null;
+			showProgress(false);
+			// if (netconnect == )
+			// {
+			//
+			// }
+
+			if (success)
+			{
+				AlertDialog.Builder builder = new Builder(
+						RetrievePasswordActivity.this);
+				builder.setMessage(getString(R.string.str_email_sent));
+
+				builder.setTitle(getString(R.string.str_retrieve_success));
+
+				builder.setPositiveButton(getString(android.R.string.ok), new OnClickListener()
+				{
+
+					@Override
+					public void onClick(DialogInterface dialog, int which)
+					{
+						dialog.dismiss();
+
+						RetrievePasswordActivity.this.finish();
+					}
+				});
+
+				// builder.setNegativeButton("取消", new OnClickListener() {
+				//
+				// @Override
+				// public void onClick(DialogInterface dialog, int which) {
+				// dialog.dismiss();
+				// }
+				// });
+
+				builder.create().show();
+
+			}
+			else
+			{
+				switch (errorcode)
+				{
+					case Network.RESULT_NET_NOTAVAILABLE:
+					{
+						Toast toast = Toast.makeText(getApplicationContext(),
+								getText(R.string.msg_connection_none),
+								Toast.LENGTH_LONG);
+						toast.setGravity(Gravity.CENTER, 0, 0);
+						toast.show();
+						return;
+					}
+					case Network.RESULT_NET_ERROR:
+					{
+						Toast toast = Toast.makeText(getApplicationContext(),
+								getText(R.string.msg_net_error),
+								Toast.LENGTH_LONG);
+						toast.setGravity(Gravity.CENTER, 0, 0);
+						toast.show();
+						return;
+					}
+					case Network.RESULT_ERROR:
+					// case Network.RESULT_RESPONSE_NULL:
+					{
+						Toast toast = Toast.makeText(getApplicationContext(),
+								getText(R.string.msg_net_resulterror),
+								Toast.LENGTH_LONG);
+						toast.setGravity(Gravity.CENTER, 0, 0);
+						toast.show();
+						return;
+					}
+
+					case Network.RESULT_FALSE:
+					{
+						AlertDialog.Builder builder = new Builder(
+								RetrievePasswordActivity.this);
+						builder.setMessage(getString(R.string.str_invalid_pore));
+
+						builder.setTitle(getString(R.string.str_retrieve_failed));
+
+						builder.setPositiveButton(getString(android.R.string.ok), new OnClickListener()
+						{
+
+							@Override
+							public void onClick(DialogInterface dialog,
+									int which)
+							{
+								dialog.dismiss();
+
+								// RetrievePasswordActivity.this.finish();
+							}
+						});
+						builder.create().show();
+						return;
+
+					}
+					default:
+					{
+						Toast toast = Toast.makeText(getApplicationContext(),
+								getText(R.string.msg_net_resulterror) + ":"
+										+ errorcode, Toast.LENGTH_LONG);
+						toast.setGravity(Gravity.CENTER, 0, 0);
+						toast.show();
+						break;
+					}
+				}
+			}
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			mAuthTask = null;
+			showProgress(false);
+		}
+	}
+}

+ 411 - 0
Apex Mobile/app/src/main/java/com/usai/apex/SearchActivity.java

@@ -0,0 +1,411 @@
+package com.usai.apex;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import com.usai.util.Network;
+import com.usai.util.dbUtil;
+
+import android.os.Bundle;
+import android.app.ListActivity;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.text.InputType;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.SimpleCursorAdapter;
+import android.widget.Switch;
+
+public class SearchActivity extends ListActivity implements OnClickListener
+{
+	private SQLiteDatabase m_db = null;
+	private Cursor m_cursor = null;
+	String user = null;
+	String password = null;
+	String function_name = null;
+	RecordsAdapter m_listadapter;
+	// private ListView m_ListView = null;
+	HashMap<String, String> hashMap = new HashMap<String, String>();
+
+	public class RecordsAdapter extends SimpleCursorAdapter
+	{
+
+		public RecordsAdapter(Context context, int layout, Cursor c,
+				String[] from, int[] to)
+		{
+			super(context, layout, c, from, to);
+			// TODO Auto-generated constructor stub
+		}
+
+		// @Override
+		// public View getView(int position, View convertView, ViewGroup parent)
+		// {
+		// // if(true)
+		// // return super.getView(position, convertView, parent);
+		// if(convertView==null)
+		// convertView = LayoutInflater.from(getApplication()).inflate(
+		// R.layout.search_lvitem_edit, null);
+		// // holder = new ViewHolder();
+		// // holder.textView = (TextView)convertView.findViewById(R.id.text);
+		// // convertView.setTag(holder);
+		// final int pos=position;
+		// // convertView = LayoutInflater.from(getApplication()).inflate(
+		// // R.layout.search_lvitem_edit, null);
+		//
+		// EditText editText = (EditText) convertView
+		// .findViewById(R.id.edit_val);
+		// // editText.setText(str);
+		//
+		// // 为editText设置TextChangedListener,每次改变的值设置到hashMap
+		// // 我们要拿到里面的值根据position拿值
+		// editText.addTextChangedListener(new TextWatcher()
+		// {
+		// @Override
+		// public void onTextChanged(CharSequence s, int start,
+		// int before, int count)
+		// {
+		//
+		// }
+		//
+		// @Override
+		// public void beforeTextChanged(CharSequence s, int start,
+		// int count, int after)
+		// {
+		//
+		// }
+		//
+		// @Override
+		// public void afterTextChanged(Editable s)
+		// {
+		// // int a = position;
+		// // 将editText中改变的值设置的HashMap中
+		// hashMap.put(pos, s.toString());
+		// }
+		// });
+		//
+		// // // 如果hashMap不为空,就设置的editText
+		// // if (hashMap.get(position) != null)
+		// // {
+		// // editText.setText(hashMap.get(position));
+		// // }
+		// return convertView;
+		// }
+
+		@Override
+		public void bindView(View view, Context context, Cursor cursor)
+		{
+			final String f0 = cursor.getString(0);
+			final String field_type = cursor.getString(1);
+			final String name = cursor.getString(2);
+
+			Log.d("cursor val", "name=" + f0 + " , type=" + field_type);
+			final EditText edit = (EditText) view.findViewById(R.id.edit_val);
+			edit.setText(hashMap.get(name));
+			Log.v("from hashmap",
+					"name=" + name + " , val=" + hashMap.get(name));
+
+//			edit.seton
+//			edit.addTextChangedListener(new TextWatcher()
+//			{
+//				@Override
+//				public void onTextChanged(CharSequence s, int start,
+//						int before, int count)
+//				{
+//
+//				}
+//
+//				@Override
+//				public void beforeTextChanged(CharSequence s, int start,
+//						int count, int after)
+//				{
+//
+//				}
+//
+//				@Override
+//				public void afterTextChanged(Editable s)
+//				{
+//					// 将editText中改变的值设置的HashMap中
+//					String val = s.toString();
+//					val.trim();
+//					if (val.length() > 0)
+//					{
+//						hashMap.put(name, val);
+//
+//						Log.i("to hashmap", "name=" + name + " , val=" + val);
+//					}
+//				}
+//			});
+			Switch switch_bool = (Switch) view.findViewById(R.id.switch_bool);
+			if (field_type.equals("boolean"))
+			{
+				edit.setVisibility(View.GONE);
+				switch_bool.setVisibility(View.VISIBLE);
+			}
+			else
+			{
+				edit.setVisibility(View.VISIBLE);
+				switch_bool.setVisibility(View.GONE);
+				if (field_type.equals("time"))
+				{
+					edit.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE
+							| InputType.TYPE_CLASS_DATETIME);
+
+				}
+				else
+					if (field_type.equals("int"))
+					{
+
+						edit.setInputType(InputType.TYPE_CLASS_NUMBER);
+					}
+					else
+					{
+						edit.setInputType(InputType.TYPE_CLASS_TEXT);
+					}
+				Log.d("ime debug", "name=" + f0 + " , type=" + field_type
+						+ ", ime=" + edit.getInputType());
+			}
+			super.bindView(view, context, cursor);
+
+			// TextView tvname = (TextView) view.findViewById(R.id.name);
+			// TextView tvinfo = (TextView) view.findViewById(R.id.info);
+			// String sname = cursor.getString(1);
+			// int iburntype = cursor.getInt(2);
+			// dbgUtil.Log(Log.INFO, "============>", "BURN TYPE =" +
+			// iburntype);
+			// if (sname == null || sname.equals(""))
+			// tvname.setVisibility(TextView.GONE);
+			// else
+			// tvname.setVisibility(View.VISIBLE);
+			// if (m_Activityinfo.NumberType != dbUtil.NUMBER_TYPE_WHITE
+			// && iburntype >= 0)
+			// {
+			//
+			// tvinfo.setText(m_arrBurntype[iburntype]);
+			// tvinfo.setVisibility(View.VISIBLE);
+			// }
+			// else
+			// {
+			// tvinfo.setVisibility(View.GONE);
+			// }
+
+		}
+
+	}
+
+	@Override
+	protected void onDestroy()
+	{
+		dbUtil.CloseDB(m_db);
+		super.onDestroy();
+	}
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		user = ApexTrackingApplication.get_user();
+		
+		password = ApexTrackingApplication.get_pass();
+		function_name = getIntent().getStringExtra("function_name");
+		setContentView(R.layout.activity_search);
+		m_db = dbUtil.OpenDB(this, null, true);
+		// m_TextView = (TextView) findViewById(R.id.summarytext);
+		// m_TextView.setText(getString(m_Activityinfo.TextViewValue));
+		// m_ListView = (ListView) findViewById(android.R.id.list);
+		m_cursor = m_db.query("fields_info", new String[] { "aname",
+				"field_type", "name", "_id" }, "function_name='"
+				+ function_name + "' and user='" + user + "' and behavior="
+				+ Network.BEHAVIOR_SEARCH + " and show = 1", null, null, null,
+				"priority , aname", null);
+		startManagingCursor(m_cursor);
+		m_listadapter = new RecordsAdapter(this,
+		// Use a template that displays a text view
+				R.layout.search_lvitem_edit,
+				// Give the cursor to the list adatper
+				m_cursor,
+				// Map the NAME column in the people database to...
+				new String[] { "aname", "field_type", "name" },
+				// The "text1" view defined in the XML template
+				new int[] { R.id.aname, R.id.tv_type });
+		setListAdapter(m_listadapter);
+		Button btnok = (Button) findViewById(R.id.btnok);
+		btnok.setOnClickListener(this);
+		Button btncancel = (Button) findViewById(R.id.btncancel);
+		btncancel.setOnClickListener(this);
+
+		SharedPreferences RunOnce = getSharedPreferences("Apex", 0);
+
+		String vername;
+		try
+		{
+			vername = getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
+			boolean bFirstRun = RunOnce.getBoolean("FirstRun" + vername
+					+ "_search", true);
+			if (bFirstRun)
+			{
+				SharedPreferences.Editor editor = RunOnce.edit();
+				editor.putBoolean("FirstRun" + vername + "_search", false);
+				// Don't forget to commit your edits!!!
+				editor.commit();
+				Intent intent = new Intent();
+				intent.setClass(this, HelpActivity.class);
+				intent.putExtra("caller", "search");
+				startActivity(intent);
+
+			}
+		}
+		catch (NameNotFoundException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		// initlist();
+
+		// m_ListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
+
+		// m_listadapter = new FieldsAdapter(this, data, resource, from, to);
+
+		// m_listadapter = new RecordsAdapter(this,
+		// // Use a template that displays a text view
+		// m_iListItemID,
+		// // Give the cursor to the list adatper
+		// m_cursor,
+		// // Map the NAME column in the people database to...
+		// m_sDispFields,
+		// // The "text1" view defined in the XML template
+		// m_iViewIDs);
+
+	}
+
+//	private void RefreshList()
+//	{
+//		// if (dbUtil.isRecordExist(m_db,
+//		// "user_numberlist","type = "+m_Activityinfo.NumberType))
+//		// {
+//		// m_TextView.setVisibility(ListView.INVISIBLE);
+//		// m_ListView.setVisibility(ListView.VISIBLE);
+//		//
+//		// }
+//		// else
+//		// {
+//		// m_TextView.setVisibility(ListView.VISIBLE);
+//		// m_ListView.setVisibility(ListView.INVISIBLE);
+//		// }
+//		hashMap.clear();
+//		m_cursor.requery();
+//	}
+
+	// private void initlist()
+	// {
+	// m_ListView = (ListView) findViewById(android.R.id.list);
+	// ArrayList<HashMap<String, Object>> list = new ArrayList<HashMap<String,
+	// Object>>();
+	// HashMap<String, Object> map = null;
+	//
+	// String[] strings = { "alias", "type", "name" };// Map的key集合数组
+	// int[] ids = { R.id.aliasName, R.id.tv_type };// 对应布局文件的id
+	// SimpleAdapter simpleAdapter = new SimpleAdapter(this, list,
+	// R.layout.search_lvitem_edit, strings, ids);
+	//
+	// // listView1.setAdapter(simpleAdapter);//绑定适配器
+	// setListAdapter(simpleAdapter);
+	// }
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.search, menu);
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		Intent intent = new Intent();
+		switch (item.getItemId())
+		{
+		case R.id.action_custom_fields:
+			intent.setClass(this, CustomizeFieldsActivity.class);
+			intent.putExtra("user", user);
+			// intent.putExtra("password", password);
+			intent.putExtra("function_name", function_name);
+			intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+			startActivity(intent);
+			break;
+		case R.id.action_help:
+			// Intent intent = new Intent();
+			intent.setClass(this, HelpActivity.class);
+			intent.putExtra("caller", "search");
+			// // intent.putExtra("password", password);
+			// intent.putExtra("function_name", function_name);
+			// intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+			startActivity(intent);
+			break;
+		default:
+			break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+
+	@Override
+	public void onClick(View v)
+	{
+		switch (v.getId())
+		{
+		case R.id.btnok:
+		{
+			Intent intent = new Intent();
+			intent.setClass(this, ResultActivity.class);
+			intent.putExtra("user", user);
+			intent.putExtra("password", password);
+			intent.putExtra("function_name", function_name);
+			Bundle parms = new Bundle();
+			parms.putString("module_name", function_name);
+			parms.putString("columns", dbUtil.get_fields(user, function_name));
+			Iterator<String> iter = hashMap.keySet().iterator();
+			while (iter.hasNext())
+			{
+				String field = (String) iter.next();
+				String val = (String) hashMap.get(field);
+				parms.putString(field, val);
+				// Cursor c = (Cursor) m_listadapter.getItem(key);
+				Log.d("@@@@@@@@@", field + " : " + val);
+			}
+			intent.putExtra("searchParms", parms);
+
+			startActivity(intent);
+
+			break;
+		}
+		case R.id.btncancel:
+			finish();
+			break;
+		default:
+			break;
+		}
+
+	}
+
+	// class FieldsAdapter extends SimpleAdapter
+	// {
+	//
+	// public FieldsAdapter(Context context,
+	// List<? extends Map<String, ?>> data, int resource,
+	// String[] from, int[] to)
+	// {
+	// super(context, data, resource, from, to);
+	// // TODO Auto-generated constructor stub
+	// }
+	//
+	// }
+
+}

+ 159 - 0
Apex Mobile/app/src/main/java/com/usai/apex/SearchHistoryActivity.java

@@ -0,0 +1,159 @@
+package com.usai.apex;
+
+import com.usai.util.dbUtil;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.AlertDialog.Builder;
+import android.content.DialogInterface;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentTransaction;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.TabHost;
+
+public class SearchHistoryActivity extends FragmentActivity
+{
+	TabHost	mTabHost;
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.search_history, menu);
+		return true;
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		// Intent intent = new Intent();
+		switch (item.getItemId())
+		{
+			case R.id.action_deleteall:
+			{
+				AlertDialog.Builder builder = new Builder(this);
+				builder.setMessage(getString(R.string.str_deletemessage));
+
+				builder.setTitle(getString(R.string.str_confirmdelete));
+
+				builder.setPositiveButton(getString(R.string.str_del),
+						new Dialog.OnClickListener()
+						{
+
+							@Override
+							public void onClick(DialogInterface dialog,
+									int which)
+							{
+								SQLiteDatabase db = dbUtil.OpenDB(
+										SearchHistoryActivity.this, null, false);
+								int a=mTabHost.getCurrentTab();
+								if(mTabHost.getCurrentTab()==0)
+								{
+									
+									db.execSQL("delete from history");
+									HistoryFragment f = (HistoryFragment)getSupportFragmentManager().findFragmentById(R.id.tab1);
+									f.searchresult.getData().clear();
+									f.adapter.notifyDataSetChanged();
+								}
+								else
+								{
+									db.execSQL("delete from favorites");
+									FavoritesFragment f = (FavoritesFragment)getSupportFragmentManager().findFragmentById(R.id.tab2);
+									f.searchresult.getData().clear();
+									f.adapter.notifyDataSetChanged();
+								}	
+
+
+								dbUtil.CloseDB(db);
+								dialog.dismiss();
+
+							}
+						});
+
+				builder.setNegativeButton(getString(R.string.str_cancel),
+						new Dialog.OnClickListener()
+						{
+
+							@Override
+							public void onClick(DialogInterface dialog,
+									int which)
+							{
+								dialog.dismiss();
+							}
+						});
+
+				builder.create().show();
+
+				break;
+			}
+			default:
+				break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		Log.d("SearchHistoryActivity", "onCreate");
+
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_search_history);
+		// ActionBar bar = getActionBar();
+		// bar.setTitle("");
+		setupTabs();
+
+	}
+	@Override
+	public boolean onKeyDown(int keyCode, KeyEvent event)
+	{
+		if (keyCode == KeyEvent.KEYCODE_BACK)
+		{
+			// Intent myIntent = new Intent();
+			// myIntent = new Intent(EditActivity.this, tabActivity.class);
+			// startActivity(myIntent);
+			finish();
+			
+			return false;
+		}
+		return super.onKeyDown(keyCode, event);
+	}
+	private void setupTabs()
+	{
+		mTabHost = (TabHost) this.findViewById(R.id.tabhost);
+
+		mTabHost.setup();
+
+		mTabHost.addTab(mTabHost
+				.newTabSpec(getString(R.string.action_saved_search))
+				.setIndicator(getString(R.string.action_saved_search))
+				.setContent(R.id.tab1));
+
+		mTabHost.addTab(mTabHost.newTabSpec(getString(R.string.action_saved_detail))
+				.setIndicator(getString(R.string.action_saved_detail))
+				.setContent(R.id.tab2));
+
+
+		Fragment favorites = new FavoritesFragment();
+		Fragment history = new HistoryFragment();
+
+		// Add the fragment to the activity, pushing this transaction
+		// on to the back stack.
+
+		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+		ft.replace(R.id.tab1, history);
+		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		ft.addToBackStack("search");
+
+		ft.replace(R.id.tab2, favorites);
+		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
+		ft.addToBackStack("detail");
+
+		ft.commit();
+
+	}
+}

+ 556 - 0
Apex Mobile/app/src/main/java/com/usai/apex/SearchListActivity.java

@@ -0,0 +1,556 @@
+package com.usai.apex;
+
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Set;
+
+import org.apache.http.entity.mime.content.StringBody;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.util.Network;
+import com.usai.util.dbUtil;
+
+import android.os.Bundle;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.AlertDialog.Builder;
+import android.app.DatePickerDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.text.Editable;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemSelectedListener;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.Button;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.Spinner;
+import android.widget.TextView;
+
+public class SearchListActivity extends Activity implements OnClickListener
+{
+
+	// String[] spin_valbool = { "True", "False" };
+	LinearLayout			ll_list;
+	String					user			= null;
+	// String password = null;
+	String					function_name	= null;
+	HashMap<String, String>	hashMap			= new HashMap<String, String>();
+
+	// private class Field
+	// {
+	// String name;
+	// String value;
+	// public Field(String n,String v)
+	// {
+	// name=n;
+	// value=v;
+	// }
+	// }
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_search_list);
+
+		user = ApexTrackingApplication.get_user();
+
+		// password = ApexTrackingApplication.get_pass();
+		function_name = getIntent().getStringExtra("function_name");
+
+		setTitle(getIntent().getStringExtra("title"));
+
+		ll_list = (LinearLayout) findViewById(R.id.ll_list);
+		Button btnok = (Button) findViewById(R.id.btnok);
+		btnok.setOnClickListener(this);
+		Button btncancel = (Button) findViewById(R.id.btncancel);
+		btncancel.setOnClickListener(this);
+		Button btnclear = (Button) findViewById(R.id.btn_clear);
+		btnclear.setOnClickListener(this);
+		if (savedInstanceState != null)
+		{
+			hashMap = (HashMap<String, String>) savedInstanceState
+					.getSerializable("hashMap");
+		}
+
+	}
+
+	@Override
+	protected void onResume()
+	{
+		init();
+		super.onResume();
+	}
+
+	void init()
+	{
+		// hashMap.clear();
+		ll_list.removeAllViews();
+		SQLiteDatabase db = dbUtil.OpenDB(this, null, true);
+		Cursor cursor = db.query("fields_info", new String[] { "aname",
+				"field_type", "name", "_id" }, "function_name='"
+				+ function_name + "' and user='" + user + "' and behavior="
+				+ Network.BEHAVIOR_SEARCH + " and show = 1", null, null, null,
+				"priority , aname", null);
+		while (cursor.moveToNext())
+		{
+			final String aname = cursor.getString(0);
+			String field_type = cursor.getString(1);
+			final String name = cursor.getString(2);
+
+			// hashMap.put(aname, field);
+
+			if (field_type.equals("boolean"))
+			{
+				RelativeLayout spinneritem = (RelativeLayout) this
+						.getLayoutInflater().inflate(
+								R.layout.search_item_spinner, null);
+				spinneritem.setTag("search_item_spinner");
+				TextView tvname = (TextView) spinneritem
+						.findViewById(R.id.aname);
+				tvname.setText(aname);
+				tvname.setTag(name);
+				Spinner spinner_bool = (Spinner) spinneritem
+						.findViewById(R.id.sp_bool);
+				ArrayAdapter<CharSequence> adapter = ArrayAdapter
+						.createFromResource(this, R.array.spinner_bool_val,
+								android.R.layout.simple_spinner_item);
+				adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+				spinner_bool.setAdapter(adapter);
+				String val = hashMap.get(name);
+				if (val != null)
+				{
+					if (val.equals("true"))
+						spinner_bool.setSelection(1);
+					else if (val.equals("false"))
+						spinner_bool.setSelection(2);
+					else
+						spinner_bool.setSelection(0);
+				}
+
+				spinner_bool
+						.setOnItemSelectedListener(new OnItemSelectedListener()
+						{
+
+							@Override
+							public void onItemSelected(AdapterView<?> arg0,
+									View arg1, int arg2, long arg3)
+							{
+								if (arg2 == 1)
+									hashMap.put(name, "true");
+								else if (arg2 == 2)
+									hashMap.put(name, "false");
+
+							}
+
+							@Override
+							public void onNothingSelected(AdapterView<?> arg0)
+							{
+
+							}
+
+						});
+				// String val = hashMap.get(name);
+				// if(val!=null)
+
+				// switch_bool.setOnCheckedChangeListener(new
+				// CompoundButton.OnCheckedChangeListener(){
+				//
+				// @Override
+				// public void onCheckedChanged(CompoundButton buttonView,
+				// boolean isChecked)
+				// {
+				// String val;
+				// if(isChecked)
+				// val="true";
+				// else
+				// val="false";
+				// Field field = new Field(name,val);
+				// field.name = name;
+				// hashMap.put(aname,field);
+				//
+				// }
+				//
+				// });
+				ll_list.addView(spinneritem);
+			}
+			else if (field_type.equals("time"))
+			{
+
+				RelativeLayout timeitem = (RelativeLayout) this
+						.getLayoutInflater().inflate(
+								R.layout.search_item_datepicker, null);
+				timeitem.setTag("search_item_datepicker");
+				TextView tvname = (TextView) timeitem.findViewById(R.id.aname);
+				tvname.setText(aname);
+				tvname.setTag(name);
+				final EditText edit_from = (EditText) timeitem
+						.findViewById(R.id.et_from);
+				final EditText edit_to = (EditText) timeitem
+						.findViewById(R.id.et_to);
+
+				String val_from = hashMap.get(name + "_from");
+				String val_to = hashMap.get(name + "_to");
+				if (val_from != null)
+				{
+					edit_from.setText(val_from);
+				}
+				if (val_to != null)
+					edit_to.setText(val_to);
+				// edit_from.setInputType(InputType.TYPE_DATETIME_VARIATION_DATE
+				// | InputType.TYPE_CLASS_DATETIME);
+				final Calendar c = Calendar.getInstance();
+				// int mYear =
+				// int mMonth = c.get(Calendar.MONTH);
+				// int mDay = c.get(Calendar.DAY_OF_MONTH);
+				// final DatePickerDialog dialog =
+				Button btn_clear_from = (Button) timeitem
+						.findViewById(R.id.btn_clear_from);
+				btn_clear_from.setOnClickListener(new OnClickListener()
+				{
+
+					@Override
+					public void onClick(View v)
+					{
+						edit_from.setText("");
+						hashMap.remove(name + "_from");
+
+					}
+
+				});
+				Button btn_clear_to = (Button) timeitem
+						.findViewById(R.id.btn_clear_to);
+				btn_clear_to.setOnClickListener(new OnClickListener()
+				{
+
+					@Override
+					public void onClick(View v)
+					{
+						edit_to.setText("");
+						hashMap.remove(name + "_to");
+
+					}
+
+				});
+
+				edit_from.setOnClickListener(new OnClickListener()
+				{
+					public void onClick(View v)
+					{
+						new DatePickerDialog(SearchListActivity.this,
+								new DatePickerDialog.OnDateSetListener()
+								{
+
+									@Override
+									public void onDateSet(DatePicker view,
+											int year, int monthOfYear,
+											int dayOfMonth)
+									{
+										edit_from
+												.setText((monthOfYear + 1)
+														+ "/" + dayOfMonth
+														+ "/" + year);
+										hashMap.put(name + "_from",
+												(monthOfYear + 1) + "/"
+														+ dayOfMonth + "/"
+														+ year);
+
+									}
+
+								}, c.get(Calendar.YEAR), c.get(Calendar.MONTH),
+								c.get(Calendar.DAY_OF_MONTH)).show();
+
+					}
+				});
+
+				edit_to.setOnClickListener(new OnClickListener()
+				{
+					public void onClick(View v)
+					{
+						new DatePickerDialog(SearchListActivity.this,
+								new DatePickerDialog.OnDateSetListener()
+								{
+
+									@Override
+									public void onDateSet(DatePicker view,
+											int year, int monthOfYear,
+											int dayOfMonth)
+									{
+										edit_to.setText((monthOfYear + 1) + "/"
+												+ dayOfMonth + "/" + year);
+										hashMap.put(name + "_to",
+												(monthOfYear + 1) + "/"
+														+ dayOfMonth + "/"
+														+ year);
+
+									}
+
+								}, c.get(Calendar.YEAR), c.get(Calendar.MONTH),
+								c.get(Calendar.DAY_OF_MONTH)).show();
+
+					}
+				});
+
+				ll_list.addView(timeitem);
+			}
+			else
+			{
+				RelativeLayout edititem = (RelativeLayout) this
+						.getLayoutInflater().inflate(R.layout.search_item_edit,
+								null);
+				edititem.setTag("search_item_edit");
+				TextView tvname = (TextView) edititem.findViewById(R.id.aname);
+				tvname.setText(aname);
+				tvname.setTag(name);
+
+				AutoCompleteTextView edit = (AutoCompleteTextView) edititem
+						.findViewById(R.id.edit_val);
+				ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
+						android.R.layout.simple_dropdown_item_1line,
+						dbUtil.get_searchhistory(name));
+				edit.setAdapter(adapter);
+
+				String val = hashMap.get(name);
+				if (val != null)
+				{
+					edit.setText(val);
+				}
+				edit.addTextChangedListener(new TextWatcher()
+				{
+					@Override
+					public void onTextChanged(CharSequence s, int start,
+							int before, int count)
+					{
+
+					}
+
+					@Override
+					public void beforeTextChanged(CharSequence s, int start,
+							int count, int after)
+					{
+
+					}
+
+					@Override
+					public void afterTextChanged(Editable s)
+					{
+						String val = s.toString();
+						val.trim();
+						if (val.length() > 0)
+						{
+
+							hashMap.put(name, val);
+						}
+					}
+
+				});
+				if (field_type.equals("int"))
+					edit.setInputType(InputType.TYPE_CLASS_NUMBER);
+
+				ll_list.addView(edititem);
+			}
+		}
+		dbUtil.CloseCursor(cursor);
+		dbUtil.CloseDB(db);
+	}
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu)
+	{
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.search_list, menu);
+		return true;
+	}
+
+	@Override
+	protected void onSaveInstanceState(Bundle outState)
+	{
+		outState.putSerializable("hashmap", hashMap);
+		super.onSaveInstanceState(outState);
+	}
+
+	@Override
+	public void onClick(View v)
+	{
+		switch (v.getId())
+		{
+			case R.id.btnok:
+			{
+				Intent intent = new Intent();
+				intent.setClass(this, ResultActivity.class);
+				// intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+				intent.putExtra("function_name", function_name);
+				Bundle parms = new Bundle();
+
+				boolean hascriterion = false;
+				for (int i = 0; i < ll_list.getChildCount(); i++)
+				{
+					View item = ll_list.getChildAt(i);
+					String tag = item.getTag().toString();
+					TextView tv_aname = (TextView) item
+							.findViewById(R.id.aname);
+					String field_name = tv_aname.getTag().toString();
+					String val = "";
+					if (tag.equals("search_item_spinner"))
+					{
+						Spinner spinner_bool = (Spinner) item
+								.findViewById(R.id.sp_bool);
+						long sel = spinner_bool.getSelectedItemId();
+						if (sel == 1)
+							val = "true";
+						else if (sel == 2)
+							val = "false";
+						else
+							val = "";
+						if (!TextUtils.isEmpty(val))
+						{
+							parms.putString(field_name, val);
+							hascriterion = true;
+						}
+					}
+					else if (tag.equals("search_item_edit"))
+					{
+						AutoCompleteTextView edit = (AutoCompleteTextView) item
+								.findViewById(R.id.edit_val);
+						val = edit.getText().toString().trim();
+						if (!TextUtils.isEmpty(val))
+						{
+							parms.putString(field_name, val);
+							hascriterion = true;
+
+							dbUtil.savehistory(field_name, val);
+						}
+					}
+					else if (tag.equals("search_item_datepicker"))
+					{
+						EditText et_from = (EditText) item
+								.findViewById(R.id.et_from);
+						String val_from = et_from.getText().toString().trim();
+						EditText et_to = (EditText) item
+								.findViewById(R.id.et_to);
+						String val_to = et_to.getText().toString().trim();
+						if (!TextUtils.isEmpty(val_from))
+						{
+							parms.putString(field_name + "_from", val_from);
+							hascriterion = true;
+						}
+						if (!TextUtils.isEmpty(val_to))
+						{
+							parms.putString(field_name + "_to", val_to);
+							hascriterion = true;
+						}
+					}
+
+				}
+				// String criterion = "";
+				// if (hascriterion)
+				// {
+				// criterion = parms.toString();
+				// }
+
+				parms.putString("module_name", function_name);
+				parms.putString("columns",
+						dbUtil.get_fields(user, function_name));
+				// Iterator<String> iter = hashMap.keySet().iterator();
+				// while (iter.hasNext())
+				// {
+				// String aname = (String) iter.next();
+				// Field field = (Field) hashMap.get(aname);
+				// parms.putString(field.name, field.value);
+				// }
+				intent.putExtra("searchParms", parms);
+
+				startActivity(intent);
+
+				break;
+			}
+			case R.id.btncancel:
+				finish();
+				break;
+			case R.id.btn_clear:
+			{
+				AlertDialog.Builder builder = new Builder(
+						SearchListActivity.this);
+				builder.setMessage("Click Reset button to reset");
+
+				builder.setTitle("Confirm reset");
+
+				builder.setPositiveButton("Reset", new Dialog.OnClickListener()
+				{
+
+					@Override
+					public void onClick(DialogInterface dialog, int which)
+					{
+						hashMap.clear();
+						init();
+						dialog.dismiss();
+
+					}
+				});
+
+				builder.setNegativeButton("Cancel",
+						new Dialog.OnClickListener()
+						{
+
+							@Override
+							public void onClick(DialogInterface dialog,
+									int which)
+							{
+								dialog.dismiss();
+							}
+						});
+
+				builder.create().show();
+			}
+			default:
+				break;
+		}
+
+	}
+
+	@Override
+	public boolean onOptionsItemSelected(MenuItem item)
+	{
+		Intent intent = new Intent();
+		switch (item.getItemId())
+		{
+			case R.id.action_custom_fields:
+				intent.setClass(this, CustomizeFieldsActivity.class);
+				// intent.putExtra("user", user);
+				// intent.putExtra("password", password);
+				intent.putExtra("function_name", function_name);
+				intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+				startActivity(intent);
+				break;
+			case R.id.action_help:
+				// Intent intent = new Intent();
+				intent.setClass(this, HelpActivity.class);
+				intent.putExtra("caller", "search");
+				// // intent.putExtra("password", password);
+				// intent.putExtra("function_name", function_name);
+				// intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+				startActivity(intent);
+				break;
+			default:
+				break;
+		}
+		return super.onOptionsItemSelected(item);
+	}
+}

+ 78 - 0
Apex Mobile/app/src/main/java/com/usai/apex/SearchResult.java

@@ -0,0 +1,78 @@
+package com.usai.apex;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import android.util.Log;
+
+public class SearchResult implements Serializable
+{
+	/**
+	 * 
+	 */
+	private static final long	serialVersionUID	= 8847830656864696392L;
+	int total_count = -1;
+	// int direction = 1;
+	int offset = 0;
+	// int count = 0;
+	ArrayList<HashMap<String, String>> records = new ArrayList<HashMap<String, String>>();
+
+	public int get_recordscount() {
+		return records.size();
+	}
+
+	public HashMap<String, String> get_record(int i) {
+		return records.get(i);
+	}
+
+	public void add_records(String jsonstr) {
+		try {
+			records.clear();
+			JSONObject objrecords = new JSONObject(jsonstr);
+			for (int i = 0; i < objrecords.length(); i++) {
+				// offset++;
+				JSONObject rec = objrecords.getJSONObject("record" + i);
+				Iterator<?> it = rec.keys();
+				HashMap<String, String> record = new HashMap<String, String>();
+				while (it.hasNext()) // loop for each function
+				{
+					String field_name = (String) it.next();
+					String val = rec.getString(field_name)
+							.replace("\n", "");
+					record.put(field_name, val);
+				}
+				records.add(record);
+
+			}
+
+		} catch (JSONException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		String TAG = "init_fields@ResultActivity.SearchResult";
+		Log.d(TAG, jsonstr);
+	}
+
+	public int get_totalcount() {
+		return total_count;
+	}
+
+	public void put_totalcount(int c) {
+		total_count = c;
+	}
+
+	public int get_offset() {
+		return offset;
+	}
+
+
+	public void set_offset(int i) {
+		offset = i;
+
+	}
+}

Diferenças do arquivo suprimidas por serem muito extensas
+ 66 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ServiceLocationFragment.java


+ 371 - 0
Apex Mobile/app/src/main/java/com/usai/apex/SettingsActivity.java

@@ -0,0 +1,371 @@
+package com.usai.apex;
+
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.content.res.Configuration;
+import android.media.Ringtone;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.ListPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceCategory;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.preference.RingtonePreference;
+import android.text.TextUtils;
+
+import java.util.List;
+
+/**
+ * A {@link PreferenceActivity} that presents a set of application settings. On
+ * handset devices, settings are presented as a single list. On tablets,
+ * settings are split by category, with category headers shown to the left of
+ * the list of settings.
+ * <p>
+ * See <a href="http://developer.android.com/design/patterns/settings.html">
+ * Android Design: Settings</a> for design guidelines and the <a
+ * href="http://developer.android.com/guide/topics/ui/settings.html">Settings
+ * API Guide</a> for more information on developing a Settings UI.
+ */
+public class SettingsActivity extends PreferenceActivity
+{
+	/**
+	 * Determines whether to always show the simplified settings UI, where
+	 * settings are presented in a single list. When false, settings are shown
+	 * as a master/detail two-pane view on tablets. When true, a single pane is
+	 * shown on tablets.
+	 */
+//	private static final boolean	ALWAYS_SIMPLE_PREFS	= false;
+//
+//	@Override
+//	protected void onPostCreate(Bundle savedInstanceState)
+//	{
+//		super.onPostCreate(savedInstanceState);
+//
+//		
+//	}
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		
+		super.onCreate(savedInstanceState);
+		setupSimplePreferencesScreen();
+		
+	}
+
+	/**
+	 * Shows the simplified settings UI if the device configuration if the
+	 * device configuration dictates that a simplified, single-pane UI should be
+	 * shown.
+	 */
+	private void setupSimplePreferencesScreen()
+	{
+//		if (!isSimplePreferences(this))
+//		{
+//			return;
+//		}
+
+		getPreferenceManager().setSharedPreferencesName("setting");
+		// In the simplified UI, fragments are not used at all and we instead
+		// use the older PreferenceActivity APIs.
+
+		// Add 'general' preferences.
+		addPreferencesFromResource(R.xml.setting);
+
+//		// Add 'notifications' preferences, and a corresponding header.
+//		PreferenceCategory fakeHeader = new PreferenceCategory(this);
+//		fakeHeader.setTitle(R.string.pref_header_notifications);
+//		getPreferenceScreen().addPreference(fakeHeader);
+//		addPreferencesFromResource(R.xml.pref_notification);
+//
+//		// Add 'data and sync' preferences, and a corresponding header.
+//		fakeHeader = new PreferenceCategory(this);
+//		fakeHeader.setTitle(R.string.pref_header_data_sync);
+//		getPreferenceScreen().addPreference(fakeHeader);
+//		addPreferencesFromResource(R.xml.pref_data_sync);
+//
+//		// Bind the summaries of EditText/List/Dialog/Ringtone preferences to
+//		// their values. When their values change, their summaries are updated
+//		// to reflect the new value, per the Android Design guidelines.
+//		bindPreferenceSummaryToValue(findPreference("example_text"));
+//		bindPreferenceSummaryToValue(findPreference("example_list"));
+//		bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone"));
+//		bindPreferenceSummaryToValue(findPreference("sync_frequency"));
+	}
+
+//	/** {@inheritDoc} */
+//	@Override
+//	public boolean onIsMultiPane()
+//	{
+//		return isXLargeTablet(this) && !isSimplePreferences(this);
+//	}
+
+	/**
+	 * Helper method to determine if the device has an extra-large screen. For
+	 * example, 10" tablets are extra-large.
+	 */
+//	private static boolean isXLargeTablet(Context context)
+//	{
+//		return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_XLARGE;
+//	}
+
+	/**
+	 * Determines whether the simplified settings UI should be shown. This is
+	 * true if this is forced via {@link #ALWAYS_SIMPLE_PREFS}, or the device
+	 * doesn't have newer APIs like {@link PreferenceFragment}, or the device
+	 * doesn't have an extra-large screen. In these cases, a single-pane
+	 * "simplified" settings UI should be shown.
+	 */
+//	private static boolean isSimplePreferences(Context context)
+//	{
+//		return ALWAYS_SIMPLE_PREFS
+//				|| Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
+//				|| !isXLargeTablet(context);
+//	}
+
+//	/** {@inheritDoc} */
+//	@Override
+//	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+//	public void onBuildHeaders(List<Header> target)
+//	{
+//		if (!isSimplePreferences(this))
+//		{
+//			loadHeadersFromResource(R.xml.pref_headers, target);
+//		}
+//	}
+
+	/**
+	 * A preference value change listener that updates the preference's summary
+	 * to reflect its new value.
+	 */
+	// private static Preference.OnPreferenceChangeListener
+	// sBindPreferenceSummaryToValueListener = new
+	// Preference.OnPreferenceChangeListener()
+	// {
+	// @Override
+	// public boolean onPreferenceChange(
+	// Preference preference,
+	// Object value)
+	// {
+	// String stringValue = value
+	// .toString();
+	//
+	// if (preference instanceof ListPreference)
+	// {
+	// // For
+	// // list
+	// // preferences,
+	// // look
+	// // up
+	// // the
+	// // correct
+	// // display
+	// // value
+	// // in
+	// // the
+	// // preference's
+	// // 'entries'
+	// // list.
+	// ListPreference listPreference = (ListPreference) preference;
+	// int index = listPreference
+	// .findIndexOfValue(stringValue);
+	//
+	// // Set
+	// // the
+	// // summary
+	// // to
+	// // reflect
+	// // the
+	// // new
+	// // value.
+	// preference
+	// .setSummary(index >= 0 ? listPreference
+	// .getEntries()[index]
+	// : null);
+	//
+	// }
+	// else if (preference instanceof RingtonePreference)
+	// {
+	// // For
+	// // ringtone
+	// // preferences,
+	// // look
+	// // up
+	// // the
+	// // correct
+	// // display
+	// // value
+	// // using
+	// // RingtoneManager.
+	// if (TextUtils
+	// .isEmpty(stringValue))
+	// {
+	// // Empty
+	// // values
+	// // correspond
+	// // to
+	// // 'silent'
+	// // (no
+	// // ringtone).
+	// preference
+	// .setSummary(R.string.pref_ringtone_silent);
+	//
+	// }
+	// else
+	// {
+	// Ringtone ringtone = RingtoneManager
+	// .getRingtone(
+	// preference
+	// .getContext(),
+	// Uri.parse(stringValue));
+	//
+	// if (ringtone == null)
+	// {
+	// // Clear
+	// // the
+	// // summary
+	// // if
+	// // there
+	// // was
+	// // a
+	// // lookup
+	// // error.
+	// preference
+	// .setSummary(null);
+	// }
+	// else
+	// {
+	// // Set
+	// // the
+	// // summary
+	// // to
+	// // reflect
+	// // the
+	// // new
+	// // ringtone
+	// // display
+	// // name.
+	// String name = ringtone
+	// .getTitle(preference
+	// .getContext());
+	// preference
+	// .setSummary(name);
+	// }
+	// }
+	//
+	// }
+	// else
+	// {
+	// // For
+	// // all
+	// // other
+	// // preferences,
+	// // set
+	// // the
+	// // summary
+	// // to
+	// // the
+	// // value's
+	// // simple
+	// // string
+	// // representation.
+	// preference
+	// .setSummary(stringValue);
+	// }
+	// return true;
+	// }
+	// };
+
+	/**
+	 * Binds a preference's summary to its value. More specifically, when the
+	 * preference's value is changed, its summary (line of text below the
+	 * preference title) is updated to reflect the value. The summary is also
+	 * immediately updated upon calling this method. The exact display format is
+	 * dependent on the type of preference.
+	 * 
+	 * @see #sBindPreferenceSummaryToValueListener
+	 */
+//	private static void bindPreferenceSummaryToValue(Preference preference)
+//	{
+//		// Set the listener to watch for value changes.
+//		preference
+//				.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
+//
+//		// Trigger the listener immediately with the preference's
+//		// current value.
+//		sBindPreferenceSummaryToValueListener.onPreferenceChange(
+//				preference,
+//				PreferenceManager.getDefaultSharedPreferences(
+//						preference.getContext()).getString(preference.getKey(),
+//						""));
+//	}
+
+	/**
+	 * This fragment shows general preferences only. It is used when the
+	 * activity is showing a two-pane settings UI.
+	 */
+//	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+//	public static class GeneralPreferenceFragment extends PreferenceFragment
+//	{
+//		@Override
+//		public void onCreate(Bundle savedInstanceState)
+//		{
+//			super.onCreate(savedInstanceState);
+//			addPreferencesFromResource(R.xml.pref_general);
+//
+//			// Bind the summaries of EditText/List/Dialog/Ringtone preferences
+//			// to their values. When their values change, their summaries are
+//			// updated to reflect the new value, per the Android Design
+//			// guidelines.
+//			bindPreferenceSummaryToValue(findPreference("example_text"));
+//			bindPreferenceSummaryToValue(findPreference("example_list"));
+//		}
+//	}
+
+	/**
+	 * This fragment shows notification preferences only. It is used when the
+	 * activity is showing a two-pane settings UI.
+	 */
+//	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+//	public static class NotificationPreferenceFragment extends
+//			PreferenceFragment
+//	{
+//		@Override
+//		public void onCreate(Bundle savedInstanceState)
+//		{
+//			super.onCreate(savedInstanceState);
+//			addPreferencesFromResource(R.xml.pref_notification);
+//
+//			// Bind the summaries of EditText/List/Dialog/Ringtone preferences
+//			// to their values. When their values change, their summaries are
+//			// updated to reflect the new value, per the Android Design
+//			// guidelines.
+//			bindPreferenceSummaryToValue(findPreference("notifications_new_message_ringtone"));
+//		}
+//	}
+
+	/**
+	 * This fragment shows data and sync preferences only. It is used when the
+	 * activity is showing a two-pane settings UI.
+	 */
+//	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
+//	public static class DataSyncPreferenceFragment extends PreferenceFragment
+//	{
+//		@Override
+//		public void onCreate(Bundle savedInstanceState)
+//		{
+//			super.onCreate(savedInstanceState);
+//			addPreferencesFromResource(R.xml.pref_data_sync);
+//
+//			// Bind the summaries of EditText/List/Dialog/Ringtone preferences
+//			// to their values. When their values change, their summaries are
+//			// updated to reflect the new value, per the Android Design
+//			// guidelines.
+//			bindPreferenceSummaryToValue(findPreference("sync_frequency"));
+//		}
+//	}
+}

+ 250 - 0
Apex Mobile/app/src/main/java/com/usai/apex/ToolsFragment.java

@@ -0,0 +1,250 @@
+package com.usai.apex;
+
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import android.R.color;
+import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.Intent.ShortcutIconResource;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.support.v4.app.ListFragment;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.SimpleAdapter;
+
+public class ToolsFragment extends ListFragment
+{
+
+	static final int PASSWORD_CHANGED = 1;
+	private static final int	REQUEST_CHANGEPASSWORD_ACTIVITY	= 2;
+	private static final int	REQUEST_LOGINACTIVITY			= 1;
+
+	private void delShortcut()
+	{
+		Intent shortcut = new Intent(
+				"com.android.launcher.action.UNINSTALL_SHORTCUT");
+
+		// 快捷方式的名称
+		shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
+				getString(R.string.app_name));
+
+		// 指定当前的Activity为快捷方式启动的对象: 如 com.everest.video.VideoPlayer
+		// 注意: ComponentName的第二个参数必须是完整的类名(包名+类名),否则无法删除快捷方式
+		String appClass = getActivity().getPackageName() + "."
+				+ getActivity().getLocalClassName();
+		ComponentName comp = new ComponentName(getActivity().getPackageName(),
+				appClass);
+		shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(
+				Intent.ACTION_MAIN).setComponent(comp));
+
+		getActivity().sendBroadcast(shortcut);
+
+	}
+
+	private void addShortcut()
+	{
+		Intent shortcut = new Intent(
+				"com.android.launcher.action.INSTALL_SHORTCUT");
+
+		// 快捷方式的名称
+		shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
+				getString(R.string.app_name));
+		shortcut.putExtra("duplicate", false); // 不允许重复创建
+
+		// 指定当前的Activity为快捷方式启动的对象: 如 com.everest.video.VideoPlayer
+		// 注意: ComponentName的第二个参数必须加上点号(.),否则快捷方式无法启动相应程序
+		ComponentName comp = new ComponentName(getActivity().getPackageName(),
+				"." + getActivity().getLocalClassName());
+		shortcut.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(
+				Intent.ACTION_MAIN).setComponent(comp));
+		// 快捷方式的图标
+		ShortcutIconResource iconRes = Intent.ShortcutIconResource.fromContext(
+				getActivity(), R.drawable.ic_launcher);
+		shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconRes);
+
+		getActivity().sendBroadcast(shortcut);
+	}
+
+	@Override
+	public void onActivityResult(int requestCode, int resultCode, Intent data)
+	{
+		switch (requestCode)
+		{
+
+//			case REQUEST_LOGINACTIVITY:
+//				if (resultCode == Activity.RESULT_CANCELED)
+//					getActivity().finish();
+//				break;
+			case REQUEST_CHANGEPASSWORD_ACTIVITY:
+				if (resultCode == Activity.RESULT_OK)
+				{
+//					String UNIQUE_STRING = "com.usai.apex.push.cancel";
+//					Intent intent = new Intent(UNIQUE_STRING);
+//					getActivity().sendBroadcast(intent);
+//					Intent i = new Intent();
+//					i.setClass(getActivity(), ApexActivity.class);
+//					startActivityForResult(i, REQUEST_LOGINACTIVITY);
+					getActivity().setResult(PASSWORD_CHANGED, null);
+					getActivity().finish();
+				}
+				break;
+			default:
+				break;
+		}
+		super.onActivityResult(requestCode, resultCode, data);
+	}
+
+	// @Override
+	// public void onActivityResult(int requestCode, int resultCode, Intent
+	// data)
+	// {
+	// switch (requestCode)
+	// {
+	// case REQUEST_LOGINACTIVITY:
+	// if (resultCode == Activity.RESULT_CANCELED)
+	// finish();
+	// break;
+	// case REQUEST_CHANGEPASSWORD_ACTIVITY:
+	// if (resultCode == Activity.RESULT_OK)
+	// {
+	// String UNIQUE_STRING = "com.usai.apex.push.cancel";
+	// Intent intent = new Intent(UNIQUE_STRING);
+	// sendBroadcast(intent);
+	// Intent i = new Intent();
+	// i.setClass(this, ApexActivity.class);
+	// startActivityForResult(i, 1);
+	// }
+	// break;
+	// default:
+	// break;
+	// }
+	//
+	// super.onActivityResult(requestCode, resultCode, data);
+	// }
+	private List<Map<String, Object>> getData()
+	{
+		boolean login = false;
+		Bundle b = getArguments();
+		
+		if(b!=null)
+		{
+		 login = b.getBoolean("Login");
+		}
+		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
+
+		Map<String, Object> map = new HashMap<String, Object>();
+		map.put("title", "Market news");
+		map.put("info", "google 1");
+		map.put("img", R.drawable.rect_market_news);
+		list.add(map);
+
+		map = new HashMap<String, Object>();
+		map.put("title", "Announcements");
+		map.put("info", "google 2");
+		map.put("img", R.drawable.rect_announcements);
+		list.add(map);
+
+		if (login)
+		{
+			map = new HashMap<String, Object>();
+			map.put("title", "Saved Detail/Search");
+			map.put("info", "google 2");
+			map.put("img", R.drawable.rect_search_history);
+			list.add(map);
+
+			map = new HashMap<String, Object>();
+			map.put("title", "Change Password");
+			map.put("img", R.drawable.rect_change_password);
+			list.add(map);
+			map = new HashMap<String, Object>();
+			map.put("title", "Setting");
+			map.put("img", R.drawable.rect_setting);
+			list.add(map);
+		}
+		
+		map = new HashMap<String, Object>();
+		map.put("title", "Apex History");
+
+		map.put("img", R.drawable.rect_history);
+		list.add(map);
+		
+		map = new HashMap<String, Object>();
+		map.put("title", "About this App");
+		map.put("info", "google 2");
+		map.put("img", R.drawable.rect_about);
+		list.add(map);
+
+		return list;
+	}
+
+	@Override
+	public void onActivityCreated(Bundle savedInstanceState)
+	{
+		super.onActivityCreated(savedInstanceState);
+		SimpleAdapter adapter = new SimpleAdapter(this.getActivity(),
+				getData(), R.layout.fragment_tools, new String[] { "title",
+						"img" }, new int[] { R.id.tv_toolname, R.id.iv_icon });
+		setListAdapter(adapter);
+		this.getListView().setBackgroundColor(Color.WHITE);
+	}
+
+	@Override
+	public void onListItemClick(ListView l, View v, int position, long id)
+	{
+		Log.d("FragmentList", "Item clicked: " + id);
+
+		String title = (String) getData().get(position).get("title");
+		Intent intent = new Intent();
+		if (title.equals("Market news"))
+		{
+			intent.setClass(getActivity(), AnnouncementActivity.class);
+			intent.putExtra("module_name", "Market News");
+		}
+		else if (title.equals("Announcements"))
+		{
+			intent.setClass(getActivity(), AnnouncementActivity.class);
+			intent.putExtra("module_name", "Announcements");
+		}
+		else if (title.equals("About this App"))
+		{
+			intent.setClass(getActivity(), AboutActivity.class);
+		}
+		else if (title.equals("Saved Detail/Search"))
+		{
+			intent.setClass(getActivity(), SearchHistoryActivity.class);
+		}
+		else if (title.equals("Change Password"))
+		{
+			intent.setClass(getActivity(), ChangePasswordActivity.class);
+
+			startActivityForResult(intent, REQUEST_CHANGEPASSWORD_ACTIVITY);
+			return;
+		}
+		else if (title.equals("Apex History"))
+		{
+			intent.setClass(getActivity(), ApexHistoryActivity.class);
+
+//			startActivityForResult(intent, REQUEST_CHANGEPASSWORD_ACTIVITY);
+//			return;
+		}
+		else if (title.equals("Setting"))
+		{
+			intent.setClass(getActivity(), SettingsActivity.class);
+
+//			startActivityForResult(intent, REQUEST_CHANGEPASSWORD_ACTIVITY);
+//			return;
+		}
+		startActivity(intent);
+
+	}
+}

+ 36 - 0
Apex Mobile/app/src/main/java/com/usai/apex/WebActivity.java

@@ -0,0 +1,36 @@
+package com.usai.apex;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+
+public class WebActivity extends Activity
+{
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+
+		// setTitle("Booking Result");
+
+		super.onCreate(savedInstanceState);
+
+		String title = getIntent().getStringExtra("title");
+
+		setTitle(title);
+		setContentView(R.layout.fragment_web);
+		String url = getIntent().getStringExtra("url");
+		WebView wv = (WebView) findViewById(R.id.wv_content);
+		
+		
+
+		WebSettings settings=wv.getSettings();
+
+		settings.setTextSize(WebSettings.TextSize.LARGER);
+
+		wv.loadUrl(url);
+
+	}
+
+}

+ 133 - 0
Apex Mobile/app/src/main/java/com/usai/util/Crypto.java

@@ -0,0 +1,133 @@
+package com.usai.util;
+
+import java.security.SecureRandom;
+
+import javax.crypto.Cipher;
+import javax.crypto.KeyGenerator;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+
+/**
+ * Usage:
+ * 
+ * <pre>
+ * String crypto = Crypto.encrypt(masterpassword, cleartext) 
+ * ... 
+ * String cleartext = Crypto.decrypt(masterpassword, crypto)
+ * </pre>
+ * 
+ * @author ferenc.hechler
+ */
+public class Crypto
+{
+//    public static SecretKeySpec setSecretKey(String password) throws Exception {
+//        SecretKeySpec key = null;
+//        KeyGenerator kgen = KeyGenerator.getInstance(ALGORITHM);
+//        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
+//        sr.setSeed(password.getBytes());
+//        kgen.init(128, sr);
+//        SecretKey secretKey = kgen.generateKey();
+//        byte[] enCodeFormat = secretKey.getEncoded();
+//        key = new SecretKeySpec(enCodeFormat, SecretKeySpec.ALGORITHM);
+//
+//        return key;
+//    }
+
+	public static String encrypt(String seed, String cleartext)
+			throws Exception
+	{
+		byte[] rawKey = getRawKey(seed.getBytes());
+		byte[] result = encrypt(rawKey, cleartext.getBytes());
+		return toHex(result);
+	}
+
+	public static String decrypt(String seed, String encrypted)
+			throws Exception
+	{
+		byte[] rawKey = getRawKey(seed.getBytes());
+		byte[] enc = toByte(encrypted);
+		byte[] result = decrypt(rawKey, enc);
+		return new String(result);
+	}
+
+	private static byte[] getRawKey(byte[] seed) throws Exception
+	{
+		
+        KeyGenerator kgen = KeyGenerator.getInstance("AES");
+        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG", "Crypto");
+        sr.setSeed(seed);
+        kgen.init(128, sr);
+        SecretKey secretKey = kgen.generateKey();	
+        byte[] enCodeFormat = secretKey.getEncoded();
+//        key = new SecretKeySpec(enCodeFormat, SecretKeySpec.ALGORITHM);
+        return enCodeFormat;
+//
+//        return key;	
+//		KeyGenerator kgen = KeyGenerator.getInstance("AES");
+//		SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
+//		sr.setSeed(seed);
+//		kgen.init(128, sr); // 192 and 256 bits may not be available
+//		SecretKey skey = kgen.generateKey();
+//		byte[] raw = skey.getEncoded();
+//		return raw;
+	}
+
+	private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception
+	{
+		SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+		Cipher cipher = Cipher.getInstance("AES");
+		cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
+		byte[] encrypted = cipher.doFinal(clear);
+		return encrypted;
+	}
+
+	private static byte[] decrypt(byte[] raw, byte[] encrypted)
+			throws Exception
+	{
+		SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
+		Cipher cipher = Cipher.getInstance("AES");
+		cipher.init(Cipher.DECRYPT_MODE, skeySpec);
+		byte[] decrypted = cipher.doFinal(encrypted);
+		return decrypted;
+	}
+
+	public static String toHex(String txt)
+	{
+		return toHex(txt.getBytes());
+	}
+
+	public static String fromHex(String hex)
+	{
+		return new String(toByte(hex));
+	}
+
+	public static byte[] toByte(String hexString)
+	{
+		int len = hexString.length() / 2;
+		byte[] result = new byte[len];
+		for (int i = 0; i < len; i++)
+			result[i] = Integer.valueOf(hexString.substring(2 * i, 2 * i + 2),
+					16).byteValue();
+		return result;
+	}
+
+	public static String toHex(byte[] buf)
+	{
+		if (buf == null)
+			return "";
+		StringBuffer result = new StringBuffer(2 * buf.length);
+		for (int i = 0; i < buf.length; i++)
+		{
+			appendHex(result, buf[i]);
+		}
+		return result.toString();
+	}
+
+	private final static String HEX = "0123456789ABCDEF";
+
+	private static void appendHex(StringBuffer sb, byte b)
+	{
+		sb.append(HEX.charAt((b >> 4) & 0x0f)).append(HEX.charAt(b & 0x0f));
+	}
+
+}

+ 1411 - 0
Apex Mobile/app/src/main/java/com/usai/util/Network.java

@@ -0,0 +1,1411 @@
+package com.usai.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+import javax.net.ssl.X509TrustManager;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.HttpVersion;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ClientConnectionManager;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.scheme.PlainSocketFactory;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.scheme.SchemeRegistry;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.entity.mime.HttpMultipartMode;
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.protocol.HTTP;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.apex.ApexTrackingApplication;
+import com.usai.apex.CustomizeFieldsActivity.fieldedit;
+
+import android.content.Context;
+import android.content.SharedPreferences.Editor;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteStatement;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+
+public class Network
+{
+	public static final int		BEHAVIOR_SEARCH					= 0;
+	public static final int		BEHAVIOR_RESULT					= 1;
+
+	private static final int	REQUEST_TIMEOUT					= 60 * 1000;										// request
+																													// time
+																													// out
+																													// 20
+																													// secs
+	private static final int	SO_TIMEOUT						= 60 * 1000;										// so
+																													// time
+																													// out
+																													// 20
+																													// secs;
+	public static int			AP_USER_AUTH					= 1;
+	public static int			AP_USER_NOT_AUTH				= 2;
+	public static int			AP_USER_NOT_EXIST				= 3;
+	public static int			AP_SESSION_EXPIRED				= 4;
+
+	public static int			AP_MESSAGE_NEW					= 5;
+	public static int			AP_MESSAGE_NONE					= 6;
+	//
+	public static final int		RESULT_FALSE					= 0;
+	public static final int		RESULT_TRUE						= -1;
+	public static final int		RESULT_NET_ERROR				= -3;
+	public static final int		RESULT_NET_NOTAVAILABLE			= -4;
+	public static final int		RESULT_ERROR					= -5;
+	public static final int		RESULT_LOCALFILE_ERROR			= -7;
+	public static final int		RESULT_USERAUTH_ERROR			= -9;
+	public static final int		RESULT_UPDATE_USERAUTH_ERROR	= -11;
+	public static final int		RESULT_SESSION_EXPIRED			= -13;
+	public static final int		RESULT_VER_LOW					= -15;
+
+	public static String		URL_UPDATE_AUTH					= "https://ra.apexshipping.com/login.php";
+	public static String		URL_REQUEST_COUNT				= "https://ra.apexshipping.com/main.php";
+	public static String		URL_REQUEST_RECORDS				= "https://ra.apexshipping.com/main.php";
+	public static String		URL_RETRIEVE_PASS				= "https://ra.apexshipping.com/main.php";
+	public static String		URL_ANNOUNCEMENTS				= "https://ra.apexshipping.com/mobile_news.php";
+	public static String		URL_NEWS						= "https://ra.apexshipping.com/mobile_news.php";
+	public static String		URL_LOCATIONS					= "https://ra.apexshipping.com/mobile_news.php";
+	public static String		URL_PUSH						= "https://ra.apexshipping.com/main.php";
+	public static String		URL_LOG						= "https://ra.apexshipping.com/mobile_news.php";
+
+	private static HttpClient getNewHttpClient()
+	{
+		try
+		{
+			KeyStore trustStore = KeyStore.getInstance(KeyStore
+					.getDefaultType());
+			trustStore.load(null, null);
+
+			SSLSocketFactory sf = new SSLSocketFactoryEx(trustStore);
+			sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+
+			HttpParams params = new BasicHttpParams();
+			HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+			HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
+			HttpConnectionParams.setConnectionTimeout(params, REQUEST_TIMEOUT);
+			HttpConnectionParams.setSoTimeout(params, SO_TIMEOUT);
+			SchemeRegistry registry = new SchemeRegistry();
+			registry.register(new Scheme("http", PlainSocketFactory
+					.getSocketFactory(), 80));
+			registry.register(new Scheme("https", sf, 443));
+
+			ClientConnectionManager ccm = new ThreadSafeClientConnManager(
+					params, registry);
+
+			return new DefaultHttpClient(ccm, params);
+		}
+		catch (Exception e)
+		{
+			return new DefaultHttpClient();
+		}
+	}
+
+	public static String get_marketnews(String id, int limit)
+	{
+		String TAG = "net_dbg@get_marketnews";
+
+		if (!Network.NetworkIsAvailable())
+		{
+			Log.d(TAG, "network not available!");
+			return null; // network not available
+		}
+
+		Bundle parms = new Bundle();
+		parms.putString("module_name", "Market News");
+		parms.putString("action_type", "search");
+		parms.putString("id", id + "");
+		parms.putString("limit", limit + "");
+		String jstr = getJson(Network.URL_NEWS, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		return jstr;
+
+	}
+
+	public static String get_servicelocation()
+	{
+		String TAG = "net_dbg@get_servicelocation";
+
+		if (!Network.NetworkIsAvailable())
+		{
+			Log.d(TAG, "network not available!");
+			return null; // network not available
+		}
+
+		Bundle parms = new Bundle();
+		parms.putString("module_name", "Location");
+		parms.putString("action_type", "search");
+		// parms.putString("id", id+"");
+		parms.putString("limit", "999");
+		String jstr = getJson(Network.URL_LOCATIONS, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		return jstr;
+
+	}
+
+	public static String get_announcements(String id, int limit)
+	{
+		String TAG = "net_dbg@get_announcements";
+
+		if (!Network.NetworkIsAvailable())
+		{
+			Log.d(TAG, "network not available!");
+			return null; // network not available
+		}
+
+		Bundle parms = new Bundle();
+		parms.putString("module_name", "Announcements");
+		parms.putString("action_type", "search");
+		parms.putString("id", id);
+		parms.putString("limit", limit + "");
+		String jstr = getJson(Network.URL_ANNOUNCEMENTS, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		return jstr;
+
+	}
+
+	public static int change_pass(String oldpass, String newpass, String user)
+	{
+		String TAG = "net_dbg@change_pass";
+		Log.d(TAG, "old:" + oldpass + ";new:" + newpass);
+		if (!Network.NetworkIsAvailable())
+		{
+			Log.d(TAG, "network not available!");
+			return Network.RESULT_NET_NOTAVAILABLE; // network not available
+		}
+		Bundle parms = new Bundle();
+		parms.putString("user", user);
+		parms.putString("oldpass", oldpass);
+		parms.putString("newpass", newpass);
+		parms.putString("module_name", "Change Password");
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
+		parms.putString("action", "handset_search");
+		String jstr = getJson(Network.URL_RETRIEVE_PASS, parms);
+		/*
+		 * error occur while get authorization info from server. include can not
+		 * reach server , wrong parms ,server get wrong , etc.
+		 */
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return Network.RESULT_NET_ERROR;
+		}
+		JSONObject jsobj;
+
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				int iresult = jsobj.getInt("result");
+				if (iresult == Network.AP_SESSION_EXPIRED)
+				{
+					Log.e(TAG, "AP_SESSION_EXPIRED");
+					Network.get_Auth(user, oldpass);
+					jstr = getJson(Network.URL_RETRIEVE_PASS, parms);
+					jsobj = new JSONObject(jstr);
+					iresult = jsobj.getInt("result");
+				}
+				if (iresult != Network.AP_USER_AUTH)
+				{
+					// user not authorized return
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return RESULT_FALSE;
+				}
+				else
+				{
+
+					return RESULT_TRUE;
+				}
+			}
+			return RESULT_NET_ERROR;
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return RESULT_NET_ERROR;
+	}
+
+	public static int retrieve_pass(String user, String email)
+	{
+		String TAG = "net_dbg@retrieve_pass";
+		Log.d(TAG, "u:" + user + ";e:" + email);
+		if (!Network.NetworkIsAvailable())
+		{
+			Log.d(TAG, "network not available!");
+			return Network.RESULT_NET_NOTAVAILABLE; // network not available
+		}
+		Bundle parms = new Bundle();
+		parms.putString("user", user);
+		parms.putString("email", email);
+		parms.putString("module_name", "Retrieve Password");
+		parms.putString("action", "handset_search");
+		String jstr = getJson(Network.URL_RETRIEVE_PASS, parms);
+		/*
+		 * error occur while get authorization info from server. include can not
+		 * reach server , wrong parms ,server get wrong , etc.
+		 */
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return Network.RESULT_NET_ERROR;
+		}
+		JSONObject jsobj;
+
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				int iresult = jsobj.getInt("result");
+
+				if (iresult != Network.AP_USER_AUTH)
+				{
+					// user not authorized return
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return RESULT_FALSE;
+				}
+				return RESULT_TRUE;
+
+			}
+			return RESULT_NET_ERROR;
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return RESULT_NET_ERROR;
+	}
+
+	public static String getJson(String url, Bundle parms)
+	{
+		String TAG = "net_dbg@GetJson";
+		Log.d(TAG, "entry");
+
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
+
+		// if (true)
+		// return fakegetJson(url);
+		try
+		{
+			// BasicHttpParams httpParams = new BasicHttpParams();
+			// HttpConnectionParams.setConnectionTimeout(httpParams,
+			// REQUEST_TIMEOUT);
+			// HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
+			HttpClient client = getNewHttpClient();// new
+													// DefaultHttpClient(httpParams);
+			HttpPost post = new HttpPost(url);
+			MultipartEntity reqEntity = new MultipartEntity(
+					HttpMultipartMode.BROWSER_COMPATIBLE);
+
+			Set<String> keys = parms.keySet();
+			Log.d(TAG, "================parms============");
+			for (String key : keys)
+			{
+				if (key.contains("_file"))
+				{
+					;
+				}
+				else
+					reqEntity.addPart(key, new StringBody(parms.get(key)
+							.toString()));
+				Log.d(TAG, "key=" + key + "    val="
+						+ parms.get(key).toString());
+			}
+			Log.d(TAG, "================parms============");
+
+			post.setEntity(reqEntity);
+			HttpResponse response = client.execute(post);
+			int statucode = response.getStatusLine().getStatusCode();
+			if (statucode == HttpStatus.SC_OK)
+			{
+				HttpEntity resEntity = response.getEntity();
+				if (resEntity != null)
+				{
+					Log.d(TAG,
+							"Response: content len==>"
+									+ resEntity.getContentLength());
+					InputStream is = resEntity.getContent();
+					try
+					{
+
+						BufferedReader br = new BufferedReader(
+								new InputStreamReader(is, "utf-8"), 8);
+						StringBuilder sb = new StringBuilder();
+						String line = null;
+						while ((line = br.readLine()) != null)
+						{
+							sb.append(line + "\n");
+						}
+
+						Log.d(TAG, "Response: content begin");
+						Log.d(TAG, sb.toString());
+						Log.d(TAG, "Response: content end");
+
+						if (sb.length() <= 0)
+						{
+
+							return null;
+						}
+						return sb.toString();
+
+					}
+					catch (Exception e)
+					{
+						Log.e(TAG, e.toString());
+						return null;
+						// TODO: handle exception
+					}
+					finally
+					{
+						is.close();
+
+					}
+
+				}
+				else
+				{
+					/*
+					 * resEntity is null
+					 */
+					Log.d(TAG, "RESPONSE ENTITY IS NULL");
+					return null;
+				}
+
+			}
+			else
+			{
+				/*
+				 * Http error; out put error code;
+				 */
+				Log.d(TAG, "HTTP " + statucode);
+
+				HttpEntity resEntity = response.getEntity();
+				if (resEntity != null)
+				{
+
+					InputStream is = resEntity.getContent();
+					try
+					{
+
+						BufferedReader br = new BufferedReader(
+								new InputStreamReader(is, "utf-8"), 8);
+						StringBuilder sb = new StringBuilder();
+						String line = null;
+						while ((line = br.readLine()) != null)
+						{
+							sb.append(line + "\n");
+						}
+
+						Log.d(TAG, "Response: content begin");
+						Log.d(TAG, sb.toString());
+						Log.d(TAG, "Response: content end");
+						return null;
+					}
+					catch (Exception e)
+					{
+						Log.e(TAG, e.toString());
+						return null;
+						// TODO: handle exception
+					}
+					finally
+					{
+						is.close();
+
+					}
+
+				}
+				else
+				{
+					/*
+					 * resEntity is null
+					 */
+					Log.e(TAG, "RESPONSE ENTITY IS NULL");
+					return null;
+				}
+			}
+
+		}
+		catch (ConnectTimeoutException e)
+		{
+			Log.d(TAG, "request time out");
+			return null;
+
+		}
+		catch (Exception e)
+		{
+			Log.d(TAG, e.toString());
+			return null;
+		}
+
+	}
+
+	public static int get_recordcount(Bundle parms)
+	{
+		String TAG = "net_dbg@get_recordcount";
+
+		parms.putString("action", "handset_search_count");
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
+		Log.d(TAG, "sessionid=" + ApexTrackingApplication.get_sessionid());
+		String jstr = getJson(Network.URL_REQUEST_COUNT, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return Network.RESULT_NET_ERROR;
+		}
+		JSONObject jsobj;
+
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				int iresult = jsobj.getInt("result");
+				if (iresult == Network.AP_SESSION_EXPIRED)
+				{
+					Log.e(TAG, "AP_SESSION_EXPIRED");
+					String user, pass;
+					user = ApexTrackingApplication.get_user();
+					pass = ApexTrackingApplication.get_pass();
+					Network.get_Auth(user, pass);
+					jstr = getJson(Network.URL_REQUEST_COUNT, parms);
+					jsobj = new JSONObject(jstr);
+					iresult = jsobj.getInt("result");
+				}
+				if (iresult != Network.AP_USER_AUTH)
+				{
+					// session expired
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return RESULT_SESSION_EXPIRED;
+					// if (get_Auth(name, password) == RESULT_TRUE)
+					// {
+					// return get_recordcount(name, password, parms);
+					//
+					// }
+					// else
+					// {
+					//
+					// Log.d(TAG,
+					// "USER NOT AUTHORIZED CODE="
+					// + jsobj.getInt("result"));
+					// return RESULT_SESSION_EXPIRED;
+					// }
+				}
+				else
+				{
+					ApexTrackingApplication.SetAuthorizeStatus(true);
+					return jsobj.getInt("count");
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return Network.RESULT_NET_ERROR;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		return RESULT_ERROR;
+	}
+
+	public static String get_records(String name, String password, Bundle parms)
+	{
+		String TAG = "net_dbg@get_records";
+		// parms.putString("user", name);
+		// parms.putString("password", password);
+		// if (!Network.NetworkIsAvailable())
+		// {
+		// Log.d(TAG, "network not available!");
+		// return "Network.RESULT_NET_NOTAVAILABLE"; // network not available
+		// }
+		parms.putString("action", "handset_search");
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
+		String jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		JSONObject jsobj;
+		//
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				int iresult = jsobj.getInt("result");
+				if (iresult == Network.AP_SESSION_EXPIRED)
+				{
+					Log.e(TAG, "AP_SESSION_EXPIRED");
+					String user, pass;
+					user = ApexTrackingApplication.get_user();
+					pass = ApexTrackingApplication.get_pass();
+					Network.get_Auth(user, pass);
+					jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
+					jsobj = new JSONObject(jstr);
+					iresult = jsobj.getInt("result");
+				}
+				if (iresult != Network.AP_USER_AUTH)
+				{
+					// session expired
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return null;
+					// if (get_Auth(name, password) == RESULT_TRUE)
+					// {
+					// return get_records(name, password, parms);
+					//
+					// }
+					// else
+					// {
+					//
+					// Log.d(TAG,
+					// "USER NOT AUTHORIZED CODE="
+					// + jsobj.getInt("result"));
+					// return null;
+					// }
+				}
+				else
+				{
+					ApexTrackingApplication.SetAuthorizeStatus(true);
+					return jstr;
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return null;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+
+		// return RESULT_ERROR;
+	}
+
+	public static String get_push(String e_id, String s_id, int limit,
+			int offset)
+	{
+		String TAG = "net_dbg@get_push";
+		Bundle parms = new Bundle();
+		parms.putString("action", "handset_search");
+		parms.putString("e_id", e_id);
+		parms.putString("s_id", s_id);
+		parms.putString("limit", limit + "");
+		parms.putString("offset", offset + "");
+		parms.putString("action_type", "detail");
+		parms.putString("module_name", "Pull Message");
+		parms.putString("uuid", commonUtil.getDUID());
+		String sessionid = ApexTrackingApplication.get_sessionid();
+		// if (TextUtils.isEmpty(sessionid))
+		// {
+		//
+		// Log.d(TAG, "no sessionid return!");
+		// return null;
+		//
+		// }
+		String user = ApexTrackingApplication.get_user();
+		// if (TextUtils.isEmpty(user))
+		// {
+		//
+		// Log.d(TAG, "no user name return!");
+		// return null;
+		//
+		// }
+		parms.putString("sessionid", sessionid);
+		parms.putString("user", user);
+		// SQLiteDatabase db =
+		// dbUtil.OpenDB(ApexTrackingApplication.get_instance(), null, false);
+		// Cursor cursor = db.query("push_message", new String[] {"MAX(e_id)"},
+		// "user = '"+ApexTrackingApplication.get_user()+"'", null, null, null,
+		// null, null);
+		// if (cursor.moveToNext())
+		// {
+		// String maxid = cursor.getString(0);
+		// if(!TextUtils.isEmpty(maxid))
+		// parms.putString("id", maxid);
+		// }
+		// dbUtil.CloseCursor(cursor);
+		// dbUtil.CloseDB(db);
+
+		String jstr = getJson(Network.URL_PUSH, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		JSONObject jsobj;
+		//
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				int iresult = jsobj.getInt("result");
+				if (iresult == Network.AP_SESSION_EXPIRED)
+				{
+					Log.e(TAG, "AP_SESSION_EXPIRED");
+					String pass;
+
+					pass = ApexTrackingApplication.get_pass();
+					Network.get_Auth(user, pass);
+					jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
+					jsobj = new JSONObject(jstr);
+					iresult = jsobj.getInt("result");
+				}
+				if (iresult != Network.AP_MESSAGE_NEW)
+				{
+					// session expired
+					Log.d(TAG,
+							"DOSE NOT GET NEW MESSAGE CODE="
+									+ jsobj.getInt("result"));
+					return null;
+					// if (get_Auth(name, password) == RESULT_TRUE)
+					// {
+					// return get_records(name, password, parms);
+					//
+					// }
+					// else
+					// {
+					//
+					// Log.d(TAG,
+					// "USER NOT AUTHORIZED CODE="
+					// + jsobj.getInt("result"));
+					// return null;
+					// }
+				}
+				else
+				{
+					return jstr;
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return null;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+
+		// return RESULT_ERROR;
+	}
+
+	public static String check_push()
+	{
+		String TAG = "net_dbg@check_push";
+		Bundle parms = new Bundle();
+		parms.putString("action", "handset_search");
+		parms.putString("module_name", "Pull Message");
+		parms.putString("uuid", commonUtil.getDUID());
+		String sessionid = ApexTrackingApplication.get_sessionid();
+		// if (TextUtils.isEmpty(sessionid))
+		// {
+		//
+		// Log.d(TAG, "no sessionid return!");
+		// return null;
+		//
+		// }
+		String user = ApexTrackingApplication.get_user();
+		if (TextUtils.isEmpty(user))
+		{
+
+			Log.d(TAG, "no user name return!");
+			return null;
+
+		}
+		// parms.putString("sessionid", sessionid);
+		parms.putString("user", user);
+		SQLiteDatabase db = dbUtil.OpenDB(
+				ApexTrackingApplication.get_instance(), null, false);
+		Cursor cursor = db.query("push_message", new String[] { "MAX(e_id)" },
+				"user = '" + ApexTrackingApplication.get_user() + "'", null,
+				null, null, null, null);
+		if (cursor.moveToNext())
+		{
+			String maxid = cursor.getString(0);
+			if (!TextUtils.isEmpty(maxid))
+				parms.putString("id", maxid);
+		}
+		dbUtil.CloseCursor(cursor);
+		dbUtil.CloseDB(db);
+
+		String jstr = getJson(Network.URL_PUSH, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		JSONObject jsobj;
+		//
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				int iresult = jsobj.getInt("result");
+				if (iresult == Network.AP_SESSION_EXPIRED)
+				{
+					Log.e(TAG, "AP_SESSION_EXPIRED");
+					String pass;
+
+					pass = ApexTrackingApplication.get_pass();
+					Network.get_Auth(user, pass);
+					jstr = getJson(Network.URL_PUSH, parms);
+					jsobj = new JSONObject(jstr);
+					iresult = jsobj.getInt("result");
+				}
+				if (iresult != Network.AP_MESSAGE_NEW)
+				{
+					// session expired
+					Log.d(TAG,
+							"DOSE NOT GET NEW MESSAGE CODE="
+									+ jsobj.getInt("result"));
+					return null;
+					// if (get_Auth(name, password) == RESULT_TRUE)
+					// {
+					// return get_records(name, password, parms);
+					//
+					// }
+					// else
+					// {
+					//
+					// Log.d(TAG,
+					// "USER NOT AUTHORIZED CODE="
+					// + jsobj.getInt("result"));
+					// return null;
+					// }
+				}
+				else
+				{
+					return jstr;
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return null;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+
+		// return RESULT_ERROR;
+	}
+
+	public static String get_detail(Bundle parms)
+	{
+		String TAG = "net_dbg@get_detail";
+		parms.putString("action", "handset_search");
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
+		String jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		JSONObject jsobj;
+		//
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				int iresult = jsobj.getInt("result");
+				if (iresult == Network.AP_SESSION_EXPIRED)
+				{
+					Log.e(TAG, "AP_SESSION_EXPIRED");
+					String user, pass;
+					user = ApexTrackingApplication.get_user();
+					pass = ApexTrackingApplication.get_pass();
+					Network.get_Auth(user, pass);
+					jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
+					jsobj = new JSONObject(jstr);
+					iresult = jsobj.getInt("result");
+				}
+				if (iresult != Network.AP_USER_AUTH)
+				{
+					// session expired
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return null;
+					// if (get_Auth(name, password) == RESULT_TRUE)
+					// {
+					// return get_records(name, password, parms);
+					//
+					// }
+					// else
+					// {
+					//
+					// Log.d(TAG,
+					// "USER NOT AUTHORIZED CODE="
+					// + jsobj.getInt("result"));
+					// return null;
+					// }
+				}
+				else
+				{
+					ApexTrackingApplication.SetAuthorizeStatus(true);
+					return jstr;
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return null;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+
+		// return RESULT_ERROR;
+	}
+
+	public static int get_Auth(String name, String password)
+	{
+
+		String TAG = "net_dbg@get_Auth";
+		Log.d(TAG, "u:" + name + ";p:" + password);
+		if (!Network.NetworkIsAvailable())
+		{
+			Log.d(TAG, "network not available!");
+			return Network.RESULT_NET_NOTAVAILABLE; // network not available
+		}
+		Bundle parms = new Bundle();
+		parms.putString("user", name);
+		parms.putString("password", password);
+		parms.putString("action", "handset_login");
+		int ver = ApexTrackingApplication
+				.get_instance()
+				.getSharedPreferences(name + "_Apex_auth", Context.MODE_PRIVATE)
+				.getInt("AuthInfoVer", 0);
+		parms.putString("auth_ver", ver + "");
+		String jstr = getJson(Network.URL_UPDATE_AUTH, parms);
+		/*
+		 * error occur while get authorization info from server. include can not
+		 * reach server , wrong parms ,server get wrong , etc.
+		 */
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return Network.RESULT_NET_ERROR;
+		}
+
+		return parse_authinfo(jstr, name, password, parms);
+	}
+
+	private static int parse_authinfo(String json, String user, String pass, Bundle parms)
+	{
+		String TAG = "net_dbg@parse_authinfo";
+		Log.d(TAG, json);
+		// JSONArray array;
+		JSONObject jsobj;
+		SQLiteDatabase db = null;
+		try
+
+		{
+
+			// array = new JSONArray(json);
+			jsobj = new JSONObject(json);
+			if (jsobj.length() > 0)
+			{
+				// JSONObject objresult = jsobj.get.getJSONObject(0);// result
+				// the
+				// server result
+				// ;
+				if (jsobj.getInt("result") != Network.AP_USER_AUTH)
+				{
+					ApexTrackingApplication.logout();
+					// user not authorized return
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return RESULT_FALSE;
+				}
+
+				JSONObject objheader = jsobj.getJSONObject("header");
+				String required_ver = objheader.getString("client_ver");
+				//String ver = objheader.getString("ver");
+				String current_ver = ApexTrackingApplication.get_instance()
+						.getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
+				if (current_ver.compareTo(required_ver) < 0)
+					return RESULT_VER_LOW;
+				// JSONObject objsessionid = jsobj.getJSONObject(1); // session
+				// id
+				// on
+				// server;
+				// ApexTrackingApplication.put_sessionid(objheader
+				// .getString("sessionid"));
+				// ApexTrackingApplication.put_user(user);
+				// ApexTrackingApplication.put_password(pass);
+				// ApexTrackingApplication.put_authorization(true);
+				ApexTrackingApplication.login(objheader.getString("sessionid"),
+						user, pass);
+				Log.d(TAG, "sessionid=" + objheader.getString("sessionid"));
+				// JSONObject objupdate = array.getJSONObject(3); // whether
+				// need
+				// update ;
+				if (objheader.getBoolean("update") == false)
+				{
+					// no update on the server;
+					return RESULT_TRUE;
+				}
+				// JSONObject objver = array.getJSONObject(4); // new version
+				// get
+				// from server;
+
+				Editor editor = ApexTrackingApplication
+						.get_instance()
+						.getSharedPreferences(user + "_Apex_auth",
+								Context.MODE_PRIVATE).edit();
+
+				editor.putInt("AuthInfoVer", objheader.getInt("ver"));
+				JSONObject objfuncs = jsobj.getJSONObject("functions");
+				Iterator<?> it = objfuncs.keys();
+				db = dbUtil.OpenDB(ApexTrackingApplication.get_instance(),
+						null, true);
+				String sql = "insert into fields_info(name,aname,field_type,function_name,behavior,priority,show,user) values(?,?,?,?,?,?,?,?)";
+				String sql1 = "insert into actions_info(name,function_name,user,priority) values(?,?,?,?)";
+
+				SQLiteStatement stat = db.compileStatement(sql);
+				SQLiteStatement stat1 = db.compileStatement(sql1);
+
+				db.beginTransaction();
+				db.execSQL("update fields_info set abandon = 1 where user ='"
+						+ user + "'");
+				db.execSQL("update actions_info set abandon = 1 where user ='"
+						+ user + "'");
+
+				String field_name, field_type, alias_name;
+				while (it.hasNext()) // loop for each function
+				{
+					String func_name = (String) it.next();
+
+					// Set<String> funset = new HashSet<String>();
+					JSONObject objfun = objfuncs.getJSONObject(func_name);
+					int behavior, priority = 999;
+					int show = 1;
+					JSONObject objbehavior = objfun.getJSONObject("search");
+					Iterator<?> itbehavior = objbehavior.keys();
+					behavior = BEHAVIOR_SEARCH;
+					while (itbehavior.hasNext()) // loop for search fields in
+													// certain function
+					{
+						String field = (String) itbehavior.next();
+						JSONObject field_info = objbehavior
+								.getJSONObject(field);
+						field_name = field_info.getString("name");
+						field_type = field_info.getString("type");
+						alias_name = field_info.getString("alias");
+						priority = field_info.getInt("priority");
+						if (priority == 999)
+							show = 0;
+						else
+							show = 1;
+						int id = dbUtil.get_recordid(db, "fields_info",
+								"name='" + field_name + "' and behavior="
+										+ behavior + " and function_name='"
+										+ func_name + "' and user='" + user
+										+ "'");
+						if (id >= 0) // record exist;
+						{
+							db.execSQL("update fields_info set abandon = 0 where _id ="
+									+ id);
+						}
+						else
+						{
+							stat.bindString(1, field_name);
+							stat.bindString(2, alias_name);
+							stat.bindString(3, field_type);
+							stat.bindString(4, func_name);
+							stat.bindLong(5, behavior);
+							stat.bindLong(6, priority);
+							stat.bindLong(7, show);
+							stat.bindString(8, user);
+							stat.executeInsert();
+						}
+					}
+
+					objbehavior = objfun.getJSONObject("result");
+					Iterator<?> itresult = objbehavior.keys();
+					behavior = BEHAVIOR_RESULT;
+					while (itresult.hasNext()) // loop for result fields in
+												// certain function
+					{
+						String field = (String) itresult.next();
+						JSONObject field_info = objbehavior
+								.getJSONObject(field);
+						field_name = field_info.getString("name");
+						field_type = field_info.getString("type");
+						alias_name = field_info.getString("alias");
+						priority = field_info.getInt("priority");
+						if (priority == 999)
+							show = 0;
+						else
+							show = 1;
+						int id = dbUtil.get_recordid(db, "fields_info",
+								"name='" + field_name + "' and behavior="
+										+ behavior + " and function_name='"
+										+ func_name + "' and user='" + user
+										+ "'");
+						if (id >= 0) // record exist;
+						{
+							db.execSQL("update fields_info set abandon = 0 where _id ="
+									+ id);
+						}
+						else
+						{
+							stat.bindString(1, field_name);
+							stat.bindString(2, alias_name);
+							stat.bindString(3, field_type);
+							stat.bindString(4, func_name);
+							stat.bindLong(5, behavior);
+							stat.bindLong(6, priority);
+							stat.bindLong(7, show);
+							stat.bindString(8, user);
+							stat.executeInsert();
+						}
+					}
+
+					// objfun.has("actions")
+					objbehavior = objfun.getJSONObject("actions");
+					Iterator<?> itactions = objbehavior.keys();
+					// behavior = BEHAVIOR_RESULT;
+					while (itactions.hasNext()) // loop for result fields in
+												// certain function
+					{
+						String actionname = (String) itactions.next();
+						int action_priority = objbehavior.getInt(actionname);
+
+						int id = dbUtil.get_recordid(db, "actions_info",
+								"name='" + actionname + "' and function_name='"
+										+ func_name + "' and user='" + user
+										+ "'");
+						if (id >= 0) // record exist;
+						{
+							db.execSQL("update actions_info set abandon = 0 , priority="
+									+ action_priority + " where _id =" + id);
+						}
+						else
+						{
+							stat1.bindString(1, actionname);
+							stat1.bindString(2, func_name);
+							stat1.bindString(3, user);
+							stat1.bindLong(4, action_priority);
+							stat1.executeInsert();
+
+						}
+					}
+				}
+				db.execSQL("delete from fields_info where abandon = 1");
+				db.execSQL("delete from actions_info where abandon = 1");
+				db.setTransactionSuccessful();
+				db.endTransaction();
+				editor.commit();
+				return RESULT_TRUE;
+			}
+			Log.d(TAG, "json is wrong");
+			return RESULT_USERAUTH_ERROR;
+		}
+		catch (JSONException e1)
+		{
+			// TODO Auto-generated catch block
+			ApexTrackingApplication.logout();
+			
+			
+			parms.putString("module_name", "Log");
+			parms.putString("action_type", "save");
+			parms.putString("return", json);
+			
+			String jstr = getJson(Network.URL_LOG, parms);
+			
+			e1.printStackTrace();
+			Log.d(TAG, "json is wrong");
+		}
+		catch (NameNotFoundException e)
+		{
+			// TODO Auto-generated catch block
+			
+			ApexTrackingApplication.logout();
+			
+			
+			parms.putString("module_name", "Log");
+			parms.putString("action_type", "save");
+			parms.putString("return", json);
+			String jstr = getJson(Network.URL_LOG, parms);
+			e.printStackTrace();
+		}
+		finally
+		{
+			dbUtil.CloseDB(db);
+		}
+
+		// try
+		// {
+		// m_RemoteVerCode = Integer
+		// .parseInt(obj.getString("verCode"));
+		// m_RemoteVerName = obj.getString("verName");
+		// m_NewVerUrl = obj.getString("URL");
+		// }
+		// catch (Exception e)
+		// {
+		// m_RemoteVerCode = -1;
+		// m_RemoteVerName = "";
+		// m_NewVerUrl = "";
+		// dbgUtil.Log(Log.INFO,TAG, "download failed json file wrong!");
+		// return false;
+		// }
+		Log.d(TAG, "json is wrong");
+		return RESULT_USERAUTH_ERROR;
+	}
+
+	// private void writeData(JSONObject allData)
+	// {
+	//
+	// File file = new File(Environment.getExternalStorageDirectory()
+	// .toString() + File.separator + "live.txt");
+	// if (!file.exists())
+	// {
+	// try
+	// {
+	// file.createNewFile();
+	// }
+	// catch (IOException e)
+	// {
+	// e.printStackTrace();
+	// }
+	// }
+	// FileOutputStream fos;
+	// OutputStreamWriter osw = null;
+	// try
+	// {
+	// fos = new FileOutputStream(file);
+	//
+	// osw = new OutputStreamWriter(fos, "UTF-8");
+	// osw.write(allData.toString());
+	// osw.flush();
+	// }
+	// catch (FileNotFoundException e)
+	// {
+	// e.printStackTrace();
+	// }
+	// catch (UnsupportedEncodingException e)
+	// {
+	// e.printStackTrace();
+	// }
+	// catch (IOException e)
+	// {
+	// e.printStackTrace();
+	// }
+	// finally
+	// {
+	// if (osw != null)
+	// {
+	// try
+	// {
+	// osw.close();
+	// }
+	// catch (IOException e)
+	// {
+	// e.printStackTrace();
+	// }
+	// }
+	// }
+	// }
+
+	public static boolean NetworkIsAvailable()// Context context)
+	{
+		String TAG = "net_dbg@CheckNetwork";
+		ConnectivityManager connManager = (ConnectivityManager) ApexTrackingApplication
+				.get_instance().getSystemService(Context.CONNECTIVITY_SERVICE);
+		// .getSystemService(Context.CONNECTIVITY_SERVICE);
+
+		NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
+		if (networkInfo == null)
+		{
+			Log.d(TAG, "can not get Active NetworkInfo!");
+			// dbgUtil.Log(Log.DEBUG, "Current Network info",
+			// "can not get Active NetworkInfo!");
+			return false;
+		}
+		NetworkInfo.State netState = networkInfo.getState();
+		if (netState != NetworkInfo.State.CONNECTED)
+		{
+			Log.d(TAG, "not Connected!State=" + netState);
+			// dbgUtil.Log(Log.DEBUG, "Current Network info",
+			// "not Connected!State=" + netState);
+			return false;
+		}
+		// int iconntype = -1;
+		// iconntype = networkInfo.getType();
+
+		// boolean bUseMobileNetwork = context.getSharedPreferences(
+		// "PhoneAsstPref", 0).getBoolean("UseMobileNetwork", false);
+		//
+		// if (bUseMobileNetwork == false
+		// && iconntype != ConnectivityManager.TYPE_WIFI && iconntype != 9/*
+		// earthnet */)
+		// {
+		// Log.d(TAG,);
+		// dbgUtil.Log(Log.DEBUG, "Current Network info",
+		// "not allowed!Connection type=" + networkInfo.getTypeName());
+		// return false;
+		// }
+		boolean bavailable = networkInfo.isAvailable();
+		String strtype = networkInfo.getTypeName();
+
+		Log.d(TAG, " type = " + strtype + " abailable = " + bavailable
+				+ " state " + netState);
+		// dbgUtil.Log(Log.INFO, "Current Network info", " type = " + strtype
+		// + " abailable = " + bavailable + " state " + netState);
+		return bavailable;
+	}
+
+	public static class SSLSocketFactoryEx extends SSLSocketFactory
+	{
+
+		SSLContext	sslContext	= SSLContext.getInstance("TLS");
+
+		public SSLSocketFactoryEx(KeyStore truststore)
+				throws NoSuchAlgorithmException, KeyManagementException,
+				KeyStoreException, UnrecoverableKeyException
+		{
+			super(truststore);
+
+			TrustManager tm = new X509TrustManager()
+			{
+				public java.security.cert.X509Certificate[] getAcceptedIssuers()
+				{
+					return null;
+				}
+
+				@Override
+				public void checkClientTrusted(
+						java.security.cert.X509Certificate[] chain,
+						String authType)
+						throws java.security.cert.CertificateException
+				{
+				}
+
+//				@Override
+//				public void checkServerTrusted(
+//						java.security.cert.X509Certificate[] chain,
+//						String authType)
+//						throws java.security.cert.CertificateException
+//				{
+//				}
+				@Override
+				public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws java.security.cert.CertificateException {
+	                try {
+	                    chain[0].checkValidity();
+	                } catch (java.security.cert.CertificateExpiredException e) {
+	                   // Logger.e(TAG, "CertificateExpiredException");
+	                    throw new java.security.cert.CertificateException("CertificateExpiredException");
+	                } catch (java.security.cert.CertificateNotYetValidException e) {
+	                    //Logger.e(TAG, "CertificateNotYetValidException");
+	                    throw new java.security.cert.CertificateException("CertificateNotYetValidException");
+	                }
+	            }
+			};
+			sslContext.init(null, new TrustManager[] { tm }, null);
+		}
+
+		@Override
+		public Socket createSocket(Socket socket, String host, int port,
+				boolean autoClose) throws IOException, UnknownHostException
+		{
+			return sslContext.getSocketFactory().createSocket(socket, host,
+					port, autoClose);
+		}
+
+		@Override
+		public Socket createSocket() throws IOException
+		{
+			return sslContext.getSocketFactory().createSocket();
+		}
+	}
+}

+ 96 - 0
Apex Mobile/app/src/main/java/com/usai/util/SqlOpenHelper.java

@@ -0,0 +1,96 @@
+package com.usai.util;
+
+//import android.R.array;
+import java.util.ArrayList;
+
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteDatabase.CursorFactory;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.util.Log;
+
+public class SqlOpenHelper extends SQLiteOpenHelper
+{
+
+	private ArrayList<String>	initSQL	= new ArrayList<String>();
+
+	public void addInitSQL(String sql)
+	{
+		initSQL.add(sql);
+
+	}
+
+	public int get_RecordCount(String tablename)
+	{
+		return 0;
+
+	}
+
+	public SQLiteDatabase OpenDB(boolean writable)
+	{
+		if (writable)
+			return getWritableDatabase();
+		else
+			return getReadableDatabase();
+	}
+
+	private void initDB(SQLiteDatabase db)
+	{
+		for (int i = 0; i < initSQL.size(); i++)
+		{
+			db.execSQL(initSQL.get(i));
+		}
+
+	}
+
+	public SqlOpenHelper(Context context, String name, CursorFactory factory,
+			int version)
+	{
+		super(context, name, factory, version);
+		// TODO Auto-generated constructor stub
+	}
+
+	@Override
+	public void onCreate(SQLiteDatabase db)
+	{
+		// TODO Auto-generated method stub
+		initDB(db);
+
+	}
+
+	@Override
+	public void onOpen(SQLiteDatabase db)
+	{
+		// TODO Auto-generated method stub
+		super.onOpen(db);
+	}
+
+	@Override
+	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
+	{
+		Log.d("DB upgrade", "from " + oldVersion + " to " + newVersion);
+
+		if (newVersion == 2)
+		{
+			db.execSQL("CREATE TABLE push_message ("
+					+ "_id INTEGER PRIMARY KEY," + "s_id VARCHAR(20),"
+					+ "e_id VARCHAR(20)," + "msgcount INTEGER,"
+					+ "message VARCHAR(20)," + "h_time timestamp,"
+					+ "create_time timestamp," + "user VARCHAR(20),"
+					+ "read BOOLEAN)");
+			db.execSQL("CREATE TABLE favorites (" + "_id INTEGER PRIMARY KEY,"
+					+ "name VARCHAR(20)," + "params VARCHAR(20),"
+					+ "action VARCHAR(20)," + "module_name VARCHAR(20),"
+					+ "detail_id VARCHAR(20)," + "action_type VARCHAR(20),"
+					+ "create_time timestamp," + "user VARCHAR(20))");
+			db.execSQL("CREATE TABLE history (" + "_id INTEGER PRIMARY KEY,"
+					+ "name VARCHAR(20)," + "params VARCHAR(20),"
+					+ "action VARCHAR(20)," + "module_name VARCHAR(20),"
+					+ "criterion VARCHAR(20)," + "create_time timestamp,"
+					+ "user VARCHAR(20))");
+			db.execSQL("ALTER TABLE search_history ADD level INTEGER");
+		}
+
+	}
+
+}

+ 54 - 0
Apex Mobile/app/src/main/java/com/usai/util/commonUtil.java

@@ -0,0 +1,54 @@
+package com.usai.util;
+
+import java.io.File;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import com.usai.apex.ApexTrackingApplication;
+
+import android.content.Context;
+import android.os.Environment;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+
+public class commonUtil
+{
+	private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
+
+	
+	
+	public static boolean localdirExist()
+	{
+
+		File folder = new File(Environment.getExternalStorageDirectory().getPath()+"/Apex Mobile");
+		return (folder.exists() && folder.isDirectory()) ? true : folder.mkdirs();
+	}
+	/**
+	 * Generate a value suitable for use in {@link #setId(int)}.
+	 * This value will not collide with ID values generated at build time by aapt for R.id.
+	 *
+	 * @return a generated ID value
+	 */
+	public static int generateViewId() {
+	    for (;;) {
+	        final int result = sNextGeneratedId.get();
+	        // aapt-generated IDs have the high byte nonzero; clamp to the range under that.
+	        int newValue = result + 1;
+	        if (newValue > 0x00FFFFFF) newValue = 1; // Roll over to 1, not 0.
+	        if (sNextGeneratedId.compareAndSet(result, newValue)) {
+	            return result;
+	        }
+	    }
+	}
+	public static  String getDUID(){
+		  final TelephonyManager tm = (TelephonyManager) ApexTrackingApplication.get_instance().getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);    
+		  final String tmDevice, tmSerial, androidId;    
+		  tmDevice = "" + tm.getDeviceId();   
+		  tmSerial = "" + tm.getSimSerialNumber();    
+		  androidId = "" + android.provider.Settings.Secure.getString(ApexTrackingApplication.get_instance().getContentResolver(),android.provider.Settings.Secure.ANDROID_ID);    
+		  UUID deviceUuid = new UUID(androidId.hashCode(), ((long)tmDevice.hashCode() << 32) | tmSerial.hashCode());    
+		  String uniqueId = deviceUuid.toString();
+		  Log.d("debug","uuid="+uniqueId);
+		  return uniqueId;
+		 }
+}

+ 383 - 0
Apex Mobile/app/src/main/java/com/usai/util/dbUtil.java

@@ -0,0 +1,383 @@
+package com.usai.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.usai.apex.ApexTrackingApplication;
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteDatabase.CursorFactory;
+import android.database.sqlite.SQLiteException;
+import android.net.Uri;
+import android.text.TextUtils;
+import android.util.Log;
+
+public class dbUtil
+{
+
+	private static final String[]	FIELD_ID	= { "_id" };
+
+	public static boolean isContentExist(Context context, Uri uri, String where)
+	{
+		boolean ret;
+		Cursor cursor = context.getContentResolver().query(uri, null, where,
+				null, null);
+		dbgUtil.dbgCursorInfo(cursor, context);
+		if (cursor.moveToNext())
+			ret = true;
+		else
+			ret = false;
+
+		dbUtil.CloseCursor(cursor);
+		return ret;
+	}
+
+	public static void CloseDB(SQLiteDatabase db)
+	{
+		if (db == null)
+			return;
+		if (db.isOpen() == false)
+			return;
+		db.close();
+		return;
+
+	}
+
+	public static void CloseCursor(Cursor c)
+	{
+		if (c == null)
+			return;
+		if (c.isClosed())
+			return;
+		c.close();
+		return;
+
+	}
+
+	public static SQLiteDatabase OpenDB(Context context, CursorFactory factory,
+			boolean writable)
+	{
+
+		SqlOpenHelper dbHelper = new SqlOpenHelper(context, "apex.db", factory,
+				2);
+		dbHelper.addInitSQL("create table users (" + "_id INTEGER PRIMARY KEY,"
+				+ "name varchar(20)," + "pass varchar(20))");
+
+		// dbHelper.addInitSQL("create table scan_records ("
+		// + "_id INTEGER PRIMARY KEY," + "submit BOOLEAN DEFAULT (0),"
+		// + "picker VARCHAR(20)," + "pid varchar(20))");
+
+		/*
+		 * 
+		 * name : field name aname: alias name for display field_type:
+		 * int,bool,varchar... function_name: Ocean Booking , Ocean B/L Info.,
+		 * ... behavior: search / result priority: display order show: whether
+		 * show this field abandon: true/false , uses for update auth_info user:
+		 * record owner
+		 */
+		dbHelper.addInitSQL("CREATE TABLE fields_info ("
+				+ "_id INTEGER PRIMARY KEY," + "name VARCHAR(20),"
+				+ "aname VARCHAR(20)," + "field_type INTEGER,"
+				+ "function_name VARCHAR(20)," + "behavior INTEGER,"
+				+ "priority INTEGER," + "show BOOLEAN," + "abandon BOOLEAN,"
+				+ "user VARCHAR(20))");
+
+		dbHelper.addInitSQL("CREATE TABLE actions_info ("
+				+ "_id INTEGER PRIMARY KEY," + "name VARCHAR(20),"
+				+ "function_name VARCHAR(20)," + "priority INTEGER,"
+				+ "abandon BOOLEAN," + "user VARCHAR(20))");
+
+		dbHelper.addInitSQL("CREATE TABLE search_history ("
+				+ "_id INTEGER PRIMARY KEY," + "h_val VARCHAR(20),"
+				+ "h_field VARCHAR(20)," + "level INTEGER,"
+				+ "h_time TIMESTAMP default (datetime('now', 'localtime')),"
+				+ "user VARCHAR(20))");
+
+		// new table must create in onupgrade function too;
+
+		dbHelper.addInitSQL("CREATE TABLE push_message ("
+				+ "_id INTEGER PRIMARY KEY," + "s_id VARCHAR(20),"
+				+ "e_id VARCHAR(20)," + "msgcount INTEGER,"
+				+ "message VARCHAR(20)," + "h_time timestamp,"
+				+ "create_time timestamp," + "user VARCHAR(20),"
+				+ "read BOOLEAN)");
+
+		dbHelper.addInitSQL("CREATE TABLE favorites ("
+				+ "_id INTEGER PRIMARY KEY," + "name VARCHAR(20),"
+				+ "params VARCHAR(20)," + "action VARCHAR(20),"
+				+ "module_name VARCHAR(20)," + "detail_id VARCHAR(20),"
+				+ "action_type VARCHAR(20)," + "create_time timestamp,"
+				+ "user VARCHAR(20))");
+		dbHelper.addInitSQL("CREATE TABLE history ("
+				+ "_id INTEGER PRIMARY KEY," + "name VARCHAR(20),"
+				+ "params VARCHAR(20)," + "action VARCHAR(20),"
+				+ "module_name VARCHAR(20)," + "criterion VARCHAR(20),"
+				+ "create_time timestamp," + "user VARCHAR(20))");
+		// dbHelper.addInitSQL("create table pics (" +
+		// "_id INTEGER PRIMARY KEY,"
+		// + "picker varchar(20)," + "err_code INTEGER ,"
+		// + "pid varchar(20)," + "local_path varchar(256))");
+
+		SQLiteDatabase db = dbHelper.OpenDB(writable);
+		return db;
+	}
+
+	public static void removeRecords(SQLiteDatabase db, String table,
+			String whereclause)
+	{
+		db.execSQL("delete from " + table + " where " + whereclause);
+	}
+
+	public static long addRecordsFromCursor(SQLiteDatabase db,
+			String tablename, Cursor source, String[] from, String[] to,
+			boolean dumpPrimaryKey, boolean dumpOneRecord)
+	{
+		int ret = -1;
+		ContentValues cv = new ContentValues();
+
+		if (from == null)
+			from = source.getColumnNames();
+
+		if (to == null)
+			to = source.getColumnNames();
+
+		if (from.length != to.length)
+			return ret;
+
+		while (source.moveToNext())
+		{
+
+			for (int i = 0; i < from.length; i++)
+			{
+				if (from[i].equals("_id"))
+				{
+					if (dumpPrimaryKey)
+						cv.put(to[i], source.getInt(i));
+				}
+				else
+				{
+					cv.put(to[i], source.getString(i));
+				}
+
+			}
+			db.insert(tablename, null, cv);
+
+			if (dumpOneRecord)
+				break;
+		}
+
+		ret = 1;
+		return ret;
+
+	}
+
+	// public static long addRecord(SQLiteDatabase db, String table,
+	// ContentValues record)
+	// {
+	// long ret = -1;
+	// try
+	// {
+	// ret = db.insert(table, null, record);
+	// }
+	// catch (SQLiteException e)
+	// {
+	// dbgUtil.Log(Log.ERROR,"sql_err", e.toString());
+	//
+	// }
+	// return ret;
+	// }
+
+	public static boolean isTableEmpty(SQLiteDatabase db, String table)
+	{
+		boolean ret = true;
+
+		Cursor cursor = null;
+		try
+		{
+
+			cursor = db.query(table, FIELD_ID, null, null, null, null, null,
+					"1");
+			if (cursor.moveToNext())
+			{
+				// cursor.close();
+				ret = false;
+			}
+			else
+				ret = true;
+		}
+		catch (SQLiteException e)
+		{
+			Log.e("sql_err", e.toString());
+		}
+		finally
+		{
+			dbUtil.CloseCursor(cursor);
+		}
+		return ret;
+	}
+
+	public static boolean isRecordExist(SQLiteDatabase db, String table,
+			String where)
+	{
+		boolean ret = false;
+		Cursor cursor = null;
+		try
+		{
+
+			cursor = db.query(table, FIELD_ID, where, null, null, null, null,
+					null);
+			if (cursor.moveToNext())
+				ret = true;
+			else
+				ret = false;
+		}
+		catch (SQLiteException e)
+		{
+			Log.e("sql_err", e.toString());
+
+		}
+		finally
+		{
+
+			dbUtil.CloseCursor(cursor);
+		}
+		return ret;
+
+	}
+
+	public static String get_fields(String user, String module)
+	{
+		SQLiteDatabase db = OpenDB(ApexTrackingApplication.get_instance()
+				.getApplicationContext(), null, false);
+		Cursor cursor = db.query("fields_info", new String[] { "name" },
+				"function_name='" + module + "' and user='" + user
+						+ "' and behavior=" + Network.BEHAVIOR_RESULT, null,
+				null, null, null, null);
+		String ret = "";
+		while (cursor.moveToNext())
+		{
+			ret += cursor.getString(0);
+			ret += ",";
+
+		}
+		ret = ret.substring(0, ret.length() - 1);
+		CloseCursor(cursor);
+		CloseDB(db);
+		return ret;
+	}
+
+	public static void cleanhistory()
+	{
+		SQLiteDatabase db = OpenDB(ApexTrackingApplication.get_instance()
+				.getApplicationContext(), null, true);
+		db.execSQL("delete from search_history where julianday('now', 'localtime')-julianday(h_time, 'localtime')>30");
+		CloseDB(db);
+	}
+
+	public static void savehistory(String field, String value)
+	{
+		if (TextUtils.isEmpty(value))
+			return;
+
+		SQLiteDatabase db = OpenDB(ApexTrackingApplication.get_instance()
+				.getApplicationContext(), null, true);
+		int _id = get_recordid(db, "search_history", "user = '"
+				+ ApexTrackingApplication.get_user() + "' and h_field='"
+				+ field + "' and h_val='" + value + "'");
+
+		if (_id >= 0)
+		{
+			String sql = "update search_history set h_time = datetime('now', 'localtime') where _id = "
+					+ _id;
+			db.execSQL(sql);
+		}
+		else
+		{
+			String sql = "insert into search_history(user,h_field,h_val) values('"
+					+ ApexTrackingApplication.get_user()
+					+ "','"
+					+ field
+					+ "','" + value + "')";
+			db.execSQL(sql);
+		}
+
+		CloseDB(db);
+		// return ret;
+	}
+
+	public static List<String> get_searchhistory(String field)
+	{
+		List<String> ret = new ArrayList<String>();
+		SQLiteDatabase db = OpenDB(ApexTrackingApplication.get_instance()
+				.getApplicationContext(), null, false);
+		Cursor cursor = db.query(
+				"search_history",
+				new String[] { "h_val" },
+				"h_field='" + field + "' and user='"
+						+ ApexTrackingApplication.get_user() + "'", null, null,
+				null, "h_time desc", null);
+
+		while (cursor.moveToNext())
+		{
+			ret.add(cursor.getString(0));
+
+		}
+
+		CloseCursor(cursor);
+		CloseDB(db);
+		return ret;
+	}
+
+	public static int get_count(SQLiteDatabase db, String table, String where)
+	{
+		int ret = 0;
+		Cursor cursor = db.query(table, new String[] { "count(*)" }, where,
+				null, null, null, null, null);
+		if (cursor.moveToNext())
+		{
+			ret = cursor.getInt(0);
+		}
+
+		dbUtil.CloseCursor(cursor);
+		return ret;
+	}
+
+	public static int get_recordid(SQLiteDatabase db, String table, String where)
+	{
+		return get_recordid(db, table, where, null);
+	}
+
+	public static int get_recordid(SQLiteDatabase db, String table,
+			String where, String Orderby)
+	{
+		int ret = -1;
+		Cursor cursor = null;
+		try
+		{
+
+			cursor = db.query(table, FIELD_ID, where, null, null, null,
+					Orderby, null);
+			if (cursor.moveToNext())
+				ret = cursor.getInt(0);
+			else
+				ret = -1;
+		}
+		catch (SQLiteException e)
+		{
+			Log.e("sql_err", e.toString());
+
+		}
+		finally
+		{
+
+			dbUtil.CloseCursor(cursor);
+		}
+		return ret;
+
+	}
+
+	// if(isTableEmpty(db,"block_records"))
+
+}

+ 119 - 0
Apex Mobile/app/src/main/java/com/usai/util/dbgUtil.java

@@ -0,0 +1,119 @@
+package com.usai.util;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.util.Log;
+
+public class dbgUtil
+{
+//	static boolean ENABLE_DEBUG = true;
+//	static boolean ENABLE_SQL_DEBUG = true;
+//	final int DEBUG_LEVEL_NONE = 8;
+//	static int DEBUG_LEVEL = Log.VERBOSE;
+
+	// private static boolean m_dbgFlag = true;
+	/*
+	 * public dbgUtil(Context context) {
+	 * 
+	 * m_dbgFlag = Boolean.parseBoolean(context.getString(R.string.flag_debug));
+	 * 
+	 * }
+	 * 
+	 * public dbgUtil(Context context) { m_dbgFlag =
+	 * Boolean.parseBoolean(context.getString(R.string.flag_debug)); return
+	 * this; }
+	 */
+	public static void Logd(String tag,String msg)
+	{
+		String pos = getTracePos();
+		Log.d(tag,msg+pos);
+	}
+//	public static void Log(int type, String tag, String msg)
+//	{
+////		if (ENABLE_DEBUG == false)
+////			return;
+////		if (type < DEBUG_LEVEL)
+////			return;
+//		String pos= getTracePos();
+//		switch (type)
+//		{
+//			case Log.ASSERT:
+//				Log.wtf(tag, msg+pos);
+//				break;
+//			case Log.DEBUG:
+//				Log.d(tag, msg+pos);
+//				break;
+//			case Log.ERROR:
+//				Log.e(tag, msg+pos);
+//				break;
+//			case Log.INFO:
+//				Log.i(tag, msg+pos);
+//				break;
+//			case Log.VERBOSE:
+//				Log.v(tag, msg+pos);
+//				break;
+//			case Log.WARN:
+//				Log.w(tag, msg+pos);
+//				break;
+//			default:
+//				Log.wtf("dbgUtil", "LOG TYPE ERROR!"+pos);
+//				break;
+//		}
+//
+//	}
+
+	private static String getTracePos()
+	{
+		// StackTraceElement[] elements =
+		// Thread.currentThread().getStackTrace();
+		StackTraceElement element = Thread.currentThread().getStackTrace()[4];
+		
+		return " at " + element.getClassName() + "." + element.getMethodName()
+				+ "("+element.getFileName()+":" + element.getLineNumber()+")" ;
+	}
+
+	public static void dbgCursorInfo(Cursor cursor, Context context/*
+																	 * , String
+																	 * TracePos
+																	 */)
+	{
+//		if (ENABLE_SQL_DEBUG == false)
+//			return;
+
+		// ----------------------debug cursor-----------------------------------
+		Log.d("sql_dbg@dbgCursorInfo", getTracePos() + "Cursor size:	" + cursor.getCount()
+				+ ";	columns count:	" + cursor.getColumnCount() + ";");
+//		dbgUtil.Log(Log.DEBUG,"sql_dbg", getTracePos() + "Cursor size:	" + cursor.getCount()
+//				+ ";	columns count:	" + cursor.getColumnCount() + ";");
+		for (int i = 0; i < cursor.getColumnCount(); i++)
+		{
+			Log.d("sql_dbg@dbgCursorInfo","column idx:	" + i + ";		column name:	"
+					+ cursor.getColumnName(i) + ";");
+//			dbgUtil.Log(Log.DEBUG,"sql_dbg",
+//					"column idx:	" + i + ";		column name:	"
+//							+ cursor.getColumnName(i) + ";");
+		}
+		// ----------------------debug cursor-----------------------------------
+
+	}
+	// public static void dbgCursorMoreInfo(Cursor cursor /*, String TracePos*/)
+	// {
+	// if(Boolean.parseBoolean(context.getString(R.string.flag_debug))==false)
+	// return;
+	//
+	//
+	// //----------------------debug cursor-----------------------------------
+	// dbgUtil.Log(Log.DEBUG,"sql_dbg",Log.getStackTraceString(new Throwable())
+	// +"Cursor size:	"+cursor.getCount()
+	// +";	columns count:	"+cursor.getColumnCount()
+	// +";");
+	// for (int i =0;i<cursor.getColumnCount();i++)
+	// {
+	// dbgUtil.Log(Log.DEBUG,"sql_dbg","column idx:	"+i
+	// +";		column name:	"+cursor.getColumnName(i)
+	// +";");
+	// }
+	// //----------------------debug cursor-----------------------------------
+	//
+	// }
+}

+ 8 - 0
Apex Mobile/app/src/main/java/com/usai/util/package-info.java

@@ -0,0 +1,8 @@
+/**
+ * 
+ */
+/**
+ * @author Ray
+ *
+ */
+package com.usai.util;

BIN
Apex Mobile/app/src/main/res/drawable-hdpi/bg_4.png


BIN
Apex Mobile/app/src/main/res/drawable-hdpi/ic_launcher.png


BIN
Apex Mobile/app/src/main/res/drawable-hdpi/ic_marker.png


BIN
Apex Mobile/app/src/main/res/drawable-hdpi/ic_test.png


BIN
Apex Mobile/app/src/main/res/drawable-ldpi/ic_test.png


BIN
Apex Mobile/app/src/main/res/drawable-mdpi/ic_launcher.png


BIN
Apex Mobile/app/src/main/res/drawable-mdpi/ic_test.png


BIN
Apex Mobile/app/src/main/res/drawable-xhdpi/ic_launcher.png


BIN
Apex Mobile/app/src/main/res/drawable-xhdpi/ic_test.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_about.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_arrow.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_cargo_tracking.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_container_detail.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_document.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_down_doc.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_exit.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_file.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_file128.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_launcher.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_launcher_new.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_message.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_message_new.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_ocean_blinfo.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_oceanbooking.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_password.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_pdf.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_pdf128.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_service_location.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_test.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/ic_tools.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/pop_bg9.9.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_about.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_announcements.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_change_password.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_history.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_market_news.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_search_documents.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_search_history.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_setting.png


BIN
Apex Mobile/app/src/main/res/drawable-xxhdpi/rect_view_download_documents.png


BIN
Apex Mobile/app/src/main/res/drawable/apexlogo_2.png


+ 14 - 0
Apex Mobile/app/src/main/res/drawable/bg_button.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <solid android:color="#FFFFFFFF" />
+
+    <stroke
+        android:width="2dp"
+        android:color="#00000000" />
+
+    <padding
+        android:left="10dp"
+        android:right="10dp" />
+
+</shape>

+ 32 - 0
Apex Mobile/app/src/main/res/drawable/bg_gardient.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item android:id="@android:id/background">
+        <shape>
+            <corners android:radius="40dip" />
+
+            <gradient
+                android:angle="270"
+                android:centerColor="#ff0000"
+                android:centerY="0.5"
+                android:endColor="#ffcccc"
+                android:startColor="#ff0000" />
+        </shape>
+    </item>
+    <item
+        android:id="@android:id/background"
+        android:bottom="15dp"
+        android:left="7dp"
+        android:right="7dp"
+        android:top="3dp">
+        <shape>
+            <corners android:radius="40dip" />
+
+            <gradient
+                android:angle="90"
+                android:endColor="#FFcccc"
+                android:startColor="#ff0000" />
+        </shape>
+    </item>
+
+</layer-list>

+ 16 - 0
Apex Mobile/app/src/main/res/drawable/detail_item.xml

@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <solid android:color="#FFFFFFFF" />
+
+    <stroke
+        android:width="1dp"
+        android:color="#00000000" />
+
+    <padding
+        android:bottom="10dp"
+        android:left="10dp"
+        android:right="10dp"
+        android:top="10dp" />
+
+</shape>

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff