Ray Zhang пре 12 година
родитељ
комит
98a72d03f4
67 измењених фајлова са 3158 додато и 0 уклоњено
  1. 9 0
      Apex/.classpath
  2. 33 0
      Apex/.project
  3. 4 0
      Apex/.settings/org.eclipse.jdt.core.prefs
  4. 69 0
      Apex/AndroidManifest.xml
  5. BIN
      Apex/ic_launcher-web.png
  6. BIN
      Apex/libs/android-support-v4.jar
  7. BIN
      Apex/libs/google-play-services.jar
  8. BIN
      Apex/libs/httpmime-4.1.1.jar
  9. 20 0
      Apex/proguard-project.txt
  10. 14 0
      Apex/project.properties
  11. BIN
      Apex/res/drawable-hdpi/bg_1.png
  12. BIN
      Apex/res/drawable-hdpi/bg_2.png
  13. BIN
      Apex/res/drawable-hdpi/bg_3.png
  14. BIN
      Apex/res/drawable-hdpi/bg_4.png
  15. BIN
      Apex/res/drawable-hdpi/bg_5.png
  16. BIN
      Apex/res/drawable-hdpi/bg_6.png
  17. BIN
      Apex/res/drawable-hdpi/ic_ace_isf.png
  18. BIN
      Apex/res/drawable-hdpi/ic_cargo_tracking.png
  19. BIN
      Apex/res/drawable-hdpi/ic_container_detail.png
  20. BIN
      Apex/res/drawable-hdpi/ic_document.png
  21. BIN
      Apex/res/drawable-hdpi/ic_down_doc.png
  22. BIN
      Apex/res/drawable-hdpi/ic_exit.png
  23. BIN
      Apex/res/drawable-hdpi/ic_launcher.png
  24. BIN
      Apex/res/drawable-hdpi/ic_ocean.png
  25. BIN
      Apex/res/drawable-hdpi/ic_ocean_blinfo.png
  26. BIN
      Apex/res/drawable-hdpi/ic_oceanbooking.png
  27. BIN
      Apex/res/drawable-hdpi/ic_other.png
  28. BIN
      Apex/res/drawable-hdpi/ic_password.png
  29. BIN
      Apex/res/drawable-hdpi/ic_shipment_info.png
  30. BIN
      Apex/res/drawable-mdpi/ic_launcher.png
  31. BIN
      Apex/res/drawable-xhdpi/ic_launcher.png
  32. BIN
      Apex/res/drawable-xxhdpi/ic_launcher.png
  33. 53 0
      Apex/res/layout/activity_apex.xml
  34. 54 0
      Apex/res/layout/activity_function_select.xml
  35. 18 0
      Apex/res/layout/activity_test.xml
  36. 63 0
      Apex/res/layout/fragment_direct_tracking.xml
  37. 157 0
      Apex/res/layout/fragment_login.xml
  38. 19 0
      Apex/res/layout/fragment_service_location.xml
  39. 27 0
      Apex/res/layout/search_lvitem_edit.xml
  40. 9 0
      Apex/res/menu/apex.xml
  41. 9 0
      Apex/res/menu/direct_tracking.xml
  42. 9 0
      Apex/res/menu/function_select.xml
  43. 8 0
      Apex/res/menu/login.xml
  44. 9 0
      Apex/res/menu/main.xml
  45. 9 0
      Apex/res/menu/test.xml
  46. 10 0
      Apex/res/values-large/styles.xml
  47. 8 0
      Apex/res/values-sw600dp/dimens.xml
  48. 9 0
      Apex/res/values-sw720dp-land/dimens.xml
  49. 11 0
      Apex/res/values-v11/styles.xml
  50. 12 0
      Apex/res/values-v14/styles.xml
  51. 7 0
      Apex/res/values/dimens.xml
  52. 15 0
      Apex/res/values/strings.xml
  53. 17 0
      Apex/res/values/strings_activity_login.xml
  54. 27 0
      Apex/res/values/styles.xml
  55. 4 0
      Apex/res/values/version.xml
  56. 8 0
      Apex/res/xml/setting.xml
  57. 124 0
      Apex/src/com/usai/apex/ApexActivity.java
  58. 33 0
      Apex/src/com/usai/apex/ApexTrackingApplication.java
  59. 47 0
      Apex/src/com/usai/apex/DirectTrackingFragment.java
  60. 62 0
      Apex/src/com/usai/apex/FunctionSelectActivity.java
  61. 437 0
      Apex/src/com/usai/apex/LoginFragment.java
  62. 61 0
      Apex/src/com/usai/apex/ServiceLocationFragment.java
  63. 986 0
      Apex/src/com/usai/util/Network.java
  64. 66 0
      Apex/src/com/usai/util/SqlOpenHelper.java
  65. 499 0
      Apex/src/com/usai/util/dbUtil.java
  66. 114 0
      Apex/src/com/usai/util/dbgUtil.java
  67. 8 0
      Apex/src/com/usai/util/package-info.java

+ 9 - 0
Apex/.classpath

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>

+ 33 - 0
Apex/.project

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>Apex</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 4 - 0
Apex/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6

+ 69 - 0
Apex/AndroidManifest.xml

@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.usai.apex"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <!-- Copied from Google Maps Library/AndroidManifest.xml. -->
+    <uses-sdk
+        android:minSdkVersion="17"
+        android:targetSdkVersion="17" />
+
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <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. -->
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@android:style/Theme.Holo.Light" 
+        android:name = "com.usai.apex.ApexTrackingApplication">
+        <meta-data
+            android:name="com.google.android.maps.v2.API_KEY"
+            android:value="AIzaSyBmXqQ2PJKQudZJPA05ei0w0sODW8vhD1U" />
+        <meta-data
+            android:name="com.google.android.gms.version"
+            android:value="@integer/google_play_services_version" />
+
+
+        <activity
+            android:name="com.usai.apex.ApexActivity"
+            android:label="@string/title_activity_apex"
+            android:windowSoftInputMode="adjustPan" >
+            <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.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" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

BIN
Apex/ic_launcher-web.png


BIN
Apex/libs/android-support-v4.jar


BIN
Apex/libs/google-play-services.jar


BIN
Apex/libs/httpmime-4.1.1.jar


+ 20 - 0
Apex/proguard-project.txt

@@ -0,0 +1,20 @@
+# 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 *;
+#}

+ 14 - 0
Apex/project.properties

@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19

BIN
Apex/res/drawable-hdpi/bg_1.png


BIN
Apex/res/drawable-hdpi/bg_2.png


BIN
Apex/res/drawable-hdpi/bg_3.png


BIN
Apex/res/drawable-hdpi/bg_4.png


BIN
Apex/res/drawable-hdpi/bg_5.png


BIN
Apex/res/drawable-hdpi/bg_6.png


BIN
Apex/res/drawable-hdpi/ic_ace_isf.png


BIN
Apex/res/drawable-hdpi/ic_cargo_tracking.png


BIN
Apex/res/drawable-hdpi/ic_container_detail.png


BIN
Apex/res/drawable-hdpi/ic_document.png


BIN
Apex/res/drawable-hdpi/ic_down_doc.png


BIN
Apex/res/drawable-hdpi/ic_exit.png


BIN
Apex/res/drawable-hdpi/ic_launcher.png


BIN
Apex/res/drawable-hdpi/ic_ocean.png


BIN
Apex/res/drawable-hdpi/ic_ocean_blinfo.png


BIN
Apex/res/drawable-hdpi/ic_oceanbooking.png


BIN
Apex/res/drawable-hdpi/ic_other.png


BIN
Apex/res/drawable-hdpi/ic_password.png


BIN
Apex/res/drawable-hdpi/ic_shipment_info.png


BIN
Apex/res/drawable-mdpi/ic_launcher.png


BIN
Apex/res/drawable-xhdpi/ic_launcher.png


BIN
Apex/res/drawable-xxhdpi/ic_launcher.png


+ 53 - 0
Apex/res/layout/activity_apex.xml

@@ -0,0 +1,53 @@
+<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/tabhost"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent" >
+
+    <RelativeLayout
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent" >
+
+        <ImageView
+            android:id="@+id/imageView1"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_above="@android:id/tabs"
+            android:scaleType="fitXY"
+            android:src="@drawable/bg_1" />
+
+        <TabWidget
+            android:id="@android:id/tabs"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true" >
+        </TabWidget>
+
+        <FrameLayout
+            android:id="@android:id/tabcontent"
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+            android:layout_above="@android:id/tabs"
+            android:layout_alignParentLeft="true" >
+
+            <FrameLayout
+                android:id="@+id/tab1"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent" >
+            </FrameLayout>
+
+            <FrameLayout
+                android:id="@+id/tab2"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent" >
+            </FrameLayout>
+
+            <FrameLayout
+                android:id="@+id/tab3"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent" >
+            </FrameLayout>
+            
+        </FrameLayout>
+    </RelativeLayout>
+
+</TabHost>

+ 54 - 0
Apex/res/layout/activity_function_select.xml

@@ -0,0 +1,54 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".FunctionSelectActivity" >
+
+    <GridLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:columnCount="3"
+         >
+
+        <ImageButton
+            android:id="@+id/ibtn_booking"
+            android:layout_gravity="left"
+            android:src="@drawable/ic_oceanbooking" />
+
+        <ImageButton
+            android:id="@+id/ibtn_info"
+            android:layout_gravity="left"
+            android:src="@drawable/ic_ocean_blinfo" />
+
+        <ImageButton
+            android:id="@+id/ibtn_detail"
+            android:layout_gravity="left"
+            android:src="@drawable/ic_container_detail" />
+
+        <ImageButton
+            android:id="@+id/ibtn_cargo"
+            android:layout_gravity="left"
+            android:src="@drawable/ic_cargo_tracking" />
+
+        <ImageButton
+            android:id="@+id/ibtn_doc"
+            android:layout_gravity="left"
+            android:src="@drawable/ic_down_doc" />
+
+        <ImageButton
+            android:id="@+id/ibtn_password"
+            android:layout_gravity="left"
+            android:src="@drawable/ic_password" />
+
+        <ImageButton
+            android:id="@+id/ibtn_exit"
+            android:layout_gravity="left"
+            android:src="@drawable/ic_exit" />
+
+    </GridLayout>
+
+</RelativeLayout>

+ 18 - 0
Apex/res/layout/activity_test.xml

@@ -0,0 +1,18 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".TestActivity" >
+
+  <fragment  
+        android:id="@+id/fragment1"  
+        android:name="com.usai.apex.LoginFragment"  
+        android:layout_width="fill_parent"  
+        android:layout_height="match_parent"  
+        />  
+
+</RelativeLayout>

+ 63 - 0
Apex/res/layout/fragment_direct_tracking.xml

@@ -0,0 +1,63 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".DirectTrackingFragment" >
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:layout_centerHorizontal="true"
+        android:orientation="vertical" >
+
+        <TextView
+            android:id="@+id/textView1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="Track your cargo by selected customers" />
+
+        <RadioGroup
+            android:id="@+id/radioGroup1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content" >
+
+            <RadioButton
+                android:id="@+id/radio0"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:checked="true"
+                android:text="House B/L number" />
+
+            <RadioButton
+                android:id="@+id/radio1"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="Air WayBill number" />
+
+            <RadioButton
+                android:id="@+id/radio2"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="Trucking number" />
+
+        </RadioGroup>
+
+        <EditText
+            android:id="@+id/editText1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ems="12" >
+
+            <requestFocus />
+        </EditText>
+
+        <Button
+            android:id="@+id/button1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="right"
+            android:text="Search" />
+    </LinearLayout>
+
+</RelativeLayout>

+ 157 - 0
Apex/res/layout/fragment_login.xml

@@ -0,0 +1,157 @@
+<!--
+ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/login_form"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".LoginFragment" >
+
+    <LinearLayout
+        style="@style/LoginFormContainer"
+        android:orientation="vertical" >
+
+        <EditText
+            android:id="@+id/user"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:hint="@string/prompt_email"
+            android:maxLines="1"
+            android:singleLine="true" />
+
+        <EditText
+            android:id="@+id/password"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:hint="@string/prompt_password"
+            android:imeActionId="@+id/login"
+            android:imeActionLabel="@string/action_sign_in_short"
+            android:imeOptions="actionUnspecified"
+            android:inputType="textPassword"
+            android:maxLines="1"
+            android:singleLine="true" />
+
+        <CheckBox
+            android:id="@+id/chk_savepass"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="right"
+            android:text="Remember Password" />
+
+        <Button
+            android:id="@+id/sign_in_button"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_gravity="right"
+            android:layout_marginTop="16dp"
+            android:paddingLeft="32dp"
+            android:paddingRight="32dp"
+            android:text="Sign in" />
+    </LinearLayout>
+
+    <LinearLayout
+        android:id="@+id/login_status"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:gravity="center_horizontal"
+        android:orientation="vertical"
+        android:visibility="invisible" >
+
+        <ProgressBar
+            style="?android:attr/progressBarStyleLarge"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="8dp" />
+
+        <TextView
+            android:id="@+id/login_status_message"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="16dp"
+            android:fontFamily="sans-serif-light"
+            android:text="@string/login_progress_signing_in"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+    </LinearLayout>
+
+</RelativeLayout>
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    tools:context=".LoginActivity" >
+
+    <!-- Login progress -->
+
+    <LinearLayout
+        android:id="@+id/login_status"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_centerInParent="true"
+        android:layout_gravity="center"
+        android:gravity="center_horizontal"
+        android:orientation="vertical"
+        android:visibility="gone" >
+
+        <ProgressBar
+            style="?android:attr/progressBarStyleLarge"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="8dp" />
+
+        <TextView
+            android:id="@+id/login_status_message"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_marginBottom="16dp"
+            android:fontFamily="sans-serif-light"
+            android:text="@string/login_progress_signing_in"
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+    </LinearLayout>
+
+    <!-- Login form -->
+
+    <ScrollView
+        android:id="@+id/login_form"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" >
+
+        <LinearLayout
+            style="@style/LoginFormContainer"
+            android:orientation="vertical" >
+
+            <EditText
+                android:id="@+id/user"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:hint="@string/prompt_email"
+                android:inputType="textAutoComplete"
+                android:maxLines="1"
+                android:singleLine="true" />
+
+            <EditText
+                android:id="@+id/password"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:hint="@string/prompt_password"
+                android:imeActionId="@+id/login"
+                android:imeActionLabel="@string/action_sign_in_short"
+                android:imeOptions="actionUnspecified"
+                android:inputType="textPassword"
+                android:maxLines="1"
+                android:singleLine="true" />
+
+            <Button
+                android:id="@+id/sign_in_button"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="right"
+                android:layout_marginTop="16dp"
+                android:paddingLeft="32dp"
+                android:paddingRight="32dp"
+                android:text="@string/action_sign_in_register" />
+        </LinearLayout>
+    </ScrollView>
+
+</RelativeLayout>

+ 19 - 0
Apex/res/layout/fragment_service_location.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" >
+
+    <FrameLayout
+        android:id="@+id/map"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent" >
+    </FrameLayout>
+
+<!--     <fragment
+        
+        android:id="@+id/map"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        class="com.google.android.gms.maps.MapFragment" /> -->
+
+</RelativeLayout>

+ 27 - 0
Apex/res/layout/search_lvitem_edit.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content" >
+
+    <TextView
+        android:id="@+id/aliasName"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentTop="true"
+        android:layout_alignParentLeft="true"
+    
+        android:text="Medium Text"
+        android:textAppearance="?android:attr/textAppearanceMedium" />
+
+    <AutoCompleteTextView
+        android:id="@+id/tv_val"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_alignParentLeft="true"
+        android:layout_below="@+id/aliasName"
+        android:ems="10"
+        android:text="AutoCompleteTextView" >
+
+    </AutoCompleteTextView>
+
+</RelativeLayout>

+ 9 - 0
Apex/res/menu/apex.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 9 - 0
Apex/res/menu/direct_tracking.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 9 - 0
Apex/res/menu/function_select.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 8 - 0
Apex/res/menu/login.xml

@@ -0,0 +1,8 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_forgot_password"
+        android:showAsAction="never"
+        android:title="@string/action_forgot_password"/>
+
+</menu>

+ 9 - 0
Apex/res/menu/main.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 9 - 0
Apex/res/menu/test.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 10 - 0
Apex/res/values-large/styles.xml

@@ -0,0 +1,10 @@
+<resources>
+
+    <style name="LoginFormContainer">
+        <item name="android:layout_width">400dp</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:layout_gravity">center</item>
+        <item name="android:padding">16dp</item>
+    </style>
+
+</resources>

+ 8 - 0
Apex/res/values-sw600dp/dimens.xml

@@ -0,0 +1,8 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw600dp devices (e.g. 7" tablets) here.
+    -->
+
+</resources>

+ 9 - 0
Apex/res/values-sw720dp-land/dimens.xml

@@ -0,0 +1,9 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+    -->
+    <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>

+ 11 - 0
Apex/res/values-v11/styles.xml

@@ -0,0 +1,11 @@
+<resources>
+
+    <!--
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Light">
+        <!-- API 11 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 12 - 0
Apex/res/values-v14/styles.xml

@@ -0,0 +1,12 @@
+<resources>
+
+    <!--
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 7 - 0
Apex/res/values/dimens.xml

@@ -0,0 +1,7 @@
+<resources>
+
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>

+ 15 - 0
Apex/res/values/strings.xml

@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">Apex</string>
+    <string name="action_settings">Settings</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="msg_net_resulterror">An error occur on server</string>
+    <string name="msg_net_error">Can not connect to server</string>
+    <string name="msg_connection_none">No available connection </string>
+    <string name="title_activity_apex">ApexActivity</string>
+    <string name="title_activity_direct_tracking">DirectTracking</string>
+    <string name="title_activity_function_select">FunctionSelectActivity</string>
+    <string name="title_activity_test">TestActivity</string>
+
+</resources>

+ 17 - 0
Apex/res/values/strings_activity_login.xml

@@ -0,0 +1,17 @@
+<resources>
+
+    <string name="title_activity_login">Login</string>
+
+    <!-- Strings related to login -->
+    <string name="prompt_email">Email</string>
+    <string name="prompt_password">Password</string>
+    <string name="action_sign_in_register"><b>Sign in</b> or register</string>
+    <string name="action_sign_in_short">Sign in</string>
+    <string name="action_forgot_password">Recover lost password</string>
+    <string name="login_progress_signing_in">Signing in&#8230;</string>
+    <string name="error_invalid_email">This email address is invalid</string>
+    <string name="error_invalid_password">This password is too short</string>
+    <string name="error_incorrect_password">This password is incorrect</string>
+    <string name="error_field_required">This field is required</string>
+
+</resources>

+ 27 - 0
Apex/res/values/styles.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <!--
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.

+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Light">
+        <!--
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.

+        -->
+    </style>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="android:Theme.Light">
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+    </style>
+
+    <style name="LoginFormContainer">
+        <item name="android:layout_width">match_parent</item>
+        <item name="android:layout_height">wrap_content</item>
+        <item name="android:padding">16dp</item>
+    </style>
+
+</resources>

+ 4 - 0
Apex/res/values/version.xml

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <integer name="google_play_services_version">4030500</integer>
+</resources>

+ 8 - 0
Apex/res/xml/setting.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+    <PreferenceCategory android:title="aaa">
+        <PreferenceCategory></PreferenceCategory>
+    </PreferenceCategory>
+    
+
+</PreferenceScreen>

+ 124 - 0
Apex/src/com/usai/apex/ApexActivity.java

@@ -0,0 +1,124 @@
+package com.usai.apex;
+
+//import com.google.android.gms.maps.SupportMapFragment;
+
+import android.os.Bundle;
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.support.v4.app.FragmentActivity;
+import android.view.Menu;
+import android.widget.TabHost;
+
+public class ApexActivity extends FragmentActivity /*implements OnTabChangeListener*/
+{
+
+	TabHost mTabHost;
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_apex);
+		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;
+	}
+    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("Login").setIndicator("Login").setContent(R.id.tab1));
+        mTabHost.addTab(mTabHost.newTabSpec("Direct Tracking").setIndicator("Direct Tracking").setContent(R.id.tab2));
+        mTabHost.addTab(mTabHost.newTabSpec("Service Location").setIndicator("Service Location").setContent(R.id.tab3));
+        
+		//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 = getFragmentManager().beginTransaction();
+	    ft.replace(R.id.tab1, 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 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
+//			
+//		}
+//	}
+}

+ 33 - 0
Apex/src/com/usai/apex/ApexTrackingApplication.java

@@ -0,0 +1,33 @@
+package com.usai.apex;
+
+import android.app.Application;
+import android.util.Log;
+
+public class ApexTrackingApplication extends Application
+{
+	static final String TAG= "ApexTrackingApplication";
+	private static ApexTrackingApplication instance;
+	private static int m_sessionid;
+
+	@Override
+	public void onCreate()
+	{
+		
+		// TODO Auto-generated method stub
+		Log.d(TAG,"onCreate");
+		super.onCreate();
+		instance = this;
+	}
+
+	public static ApexTrackingApplication get_instance()
+	{
+		return instance;
+	}
+
+	public static void put_sessionid(int id)
+	{
+
+		m_sessionid = id;
+	}
+
+}

+ 47 - 0
Apex/src/com/usai/apex/DirectTrackingFragment.java

@@ -0,0 +1,47 @@
+package com.usai.apex;
+
+import android.os.Bundle;
+import android.app.Fragment;
+//import android.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+
+public class DirectTrackingFragment extends Fragment implements OnClickListener
+{
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState)
+	{
+		View view = inflater.inflate(R.layout.fragment_direct_tracking, null);
+		Button btn = (Button) view.findViewById(R.id.button1);
+		btn.setOnClickListener(this);
+		return view;
+		// return super.onCreateView(inflater, container, savedInstanceState);
+	}
+
+	@Override
+	public void onClick(View v)
+	{
+		// TODO Auto-generated method stub
+		
+	}
+
+//	@Override
+//	protected void onCreate(Bundle savedInstanceState)
+//	{
+//		super.onCreate(savedInstanceState);
+//		setContentView(R.layout.fragment_direct_tracking);
+//	}
+//
+//	@Override
+//	public boolean onCreateOptionsMenu(Menu menu)
+//	{
+//		// Inflate the menu; this adds items to the action bar if it is present.
+//		getMenuInflater().inflate(R.menu.direct_tracking, menu);
+//		return true;
+//	}
+
+}

+ 62 - 0
Apex/src/com/usai/apex/FunctionSelectActivity.java

@@ -0,0 +1,62 @@
+package com.usai.apex;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.view.Menu;
+import android.view.View;
+import android.view.View.OnClickListener;
+
+public class FunctionSelectActivity extends FragmentActivity implements OnClickListener
+{
+
+	@Override
+	protected void onCreate(Bundle savedInstanceState)
+	{
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_function_select);
+	}
+
+	@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
+	public void onClick(View v)
+	{
+		switch (v.getId())
+		{
+		case R.id.ibtn_booking:
+			
+			break;
+		case R.id.ibtn_info:
+			
+			break;
+		case R.id.ibtn_detail:
+			
+			break;
+		case R.id.ibtn_cargo:
+			
+			break;
+		case R.id.ibtn_doc:
+			
+			break;
+		case R.id.ibtn_password:
+			
+			break;
+		case R.id.ibtn_exit:
+			
+			break;
+
+		default:
+			break;
+		}
+		// TODO Auto-generated method stub
+		
+		
+	}
+
+}

+ 437 - 0
Apex/src/com/usai/apex/LoginFragment.java

@@ -0,0 +1,437 @@
+package com.usai.apex;
+
+//import android.app.Fragment;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.util.Network;
+
+import android.R.integer;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.app.Fragment;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Build;
+//import android.content.SharedPreferences;
+import android.os.Bundle;
+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.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;
+
+	// SQLiteDatabase m_db;
+
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState)
+	{
+		View view = inflater.inflate(R.layout.fragment_login, null);
+		// Button btn = (Button) view.findViewById(R.id.sign_in_button);
+		// btn.setOnClickListener(this);
+
+		// 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_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);
+					}
+				});
+		return view;
+		// return super.onCreateView(inflater, container, savedInstanceState);
+	}
+
+	// @Override
+	// public void onClick(View v)
+	// {
+	// // TODO Auto-generated method stub
+	// if (v.getId() == R.id.sign_in_button)
+	// {
+	// SharedPreferences sharedPrefrences = getActivity()
+	// .getSharedPreferences("test", Context.MODE_PRIVATE);
+	// Intent intent = new Intent();
+	// intent.setClass(getActivity(), FunctionSelectActivity.class);
+	// getActivity().startActivity(intent);
+	// }
+	//
+	// }
+
+	// /**
+	// * A dummy authentication store containing known user names and passwords.
+	// * TODO: remove after connecting to a real authentication system.
+	// */
+	// private static final String[] DUMMY_CREDENTIALS = new String[] {
+	// "foo@example.com:hello", "bar@example.com:world" };
+	//
+	// /**
+	// * The default email to populate the email field with.
+	// */
+	// public static final String EXTRA_EMAIL =
+	// "com.example.android.authenticatordemo.extra.EMAIL";
+	//
+	// /**
+	// * 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 mUser;
+	// private String mPassword;
+	//
+	// // UI references.
+	// private EditText mUserView;
+	// private EditText mPasswordView;
+
+	// @Override
+	// protected void onCreate(Bundle savedInstanceState)
+	// {
+	// super.onCreate(savedInstanceState);
+	//
+	// setContentView(R.layout.activity_login);
+	//
+	// // Set up the login form.
+	// mUser = getIntent().getStringExtra(EXTRA_EMAIL);
+	// mUserView = (EditText) findViewById(R.id.email);
+	// mUserView.setText(mUser);
+	//
+	// mPasswordView = (EditText) findViewById(R.id.password);
+	// mPasswordView
+	// .setOnEditorActionListener(new TextView.OnEditorActionListener()
+	// {
+	// @Override
+	// public boolean onEditorAction(TextView textView, int id,
+	// KeyEvent keyEvent)
+	// {
+	// if (id == R.id.login || id == EditorInfo.IME_NULL)
+	// {
+	// attemptLogin();
+	// 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.sign_in_button).setOnClickListener(
+	// new View.OnClickListener()
+	// {
+	// @Override
+	// public void onClick(View view)
+	// {
+	// attemptLogin();
+	// }
+	// });
+	// }
+	//
+	// @Override
+	// public boolean onCreateOptionsMenu(Menu menu)
+	// {
+	// super.onCreateOptionsMenu(menu);
+	// getMenuInflater().inflate(R.menu.login, 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 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.i("onPostExecute", "entry");
+			mAuthTask = null;
+			showProgress(false);
+			// if (netconnect == )
+			// {
+			//
+			// }
+			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_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;
+			}
+
+			default:
+				break;
+			}
+
+			if (success)
+			{
+
+				// SharedPreferences.Editor editor = RunOnce.edit();
+				// editor.putBoolean("FirstRun"+globalUtil.getVerName(this),
+				// false);
+				// // Don't forget to commit your edits!!!
+				// editor.commit();
+
+				Intent intent = new Intent();
+				intent.setClass(getActivity(), FunctionSelectActivity.class);
+				intent.putExtra("user", m_sUser);
+				intent.putExtra("password", m_sPassword);
+				startActivity(intent);
+				getActivity().finish();
+			}
+			else
+			{
+				m_etPassword
+						.setError(getString(R.string.error_incorrect_password));
+				m_etPassword.requestFocus();
+			}
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			mAuthTask = null;
+			showProgress(false);
+		}
+	}
+}

+ 61 - 0
Apex/src/com/usai/apex/ServiceLocationFragment.java

@@ -0,0 +1,61 @@
+package com.usai.apex;
+
+//
+//import com.google.android.gms.maps.GoogleMap;
+//import com.google.android.gms.maps.MapFragment;
+//import com.google.android.gms.maps.SupportMapFragment;
+//import com.google.android.gms.maps.model.LatLng;
+//import com.google.android.gms.maps.model.MarkerOptions;
+
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.MapFragment;
+import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MarkerOptions;
+
+import android.app.Fragment;
+import android.app.FragmentManager;
+//import android.app.FragmentManager;
+//import android.app.Fragment;
+//import android.app.FragmentManager;
+//import android.app.FragmentManager;
+import android.os.Bundle;
+
+
+//import android.support.v4.app.FragmentManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class ServiceLocationFragment extends Fragment
+{
+	
+	private MapFragment fragment;
+	private GoogleMap map;
+//	
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+		return inflater.inflate(R.layout.fragment_service_location, container, false);
+	}
+
+	@Override
+	public void onActivityCreated(Bundle savedInstanceState) {
+		super.onActivityCreated(savedInstanceState);
+		FragmentManager fm = getChildFragmentManager();
+		fragment = (MapFragment) fm.findFragmentById(R.id.map);
+		if (fragment == null) {
+			fragment = new MapFragment();//.newInstance();
+			fm.beginTransaction().replace(R.id.map, fragment).commit();
+		}
+	}
+	
+	@Override
+	public void onResume() {
+		super.onResume();
+		if (map == null) {
+			map = fragment.getMap();
+			map.addMarker(new MarkerOptions().position(new LatLng(30.650208,104.083663)));
+			map.addMarker(new MarkerOptions().position(new LatLng(37.52112,-122.03639)));
+		}
+	}
+}

+ 986 - 0
Apex/src/com/usai/util/Network.java

@@ -0,0 +1,986 @@
+package com.usai.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.entity.mime.HttpMultipartMode;
+import org.apache.http.entity.mime.MultipartEntity;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import com.usai.apex.ApexTrackingApplication;
+
+import android.R.integer;
+import android.R.string;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences.Editor;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
+
+public class Network
+{
+	private static final int REQUEST_TIMEOUT = 5 * 1000;// request time out 20
+														// secs
+	private static final int SO_TIMEOUT = 5 * 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_UPLOAD_SUCCESS = 4;
+	public static int AP_UPLOAD_FAIL = 5;
+	//
+	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_NOCONNECT = 2;
+	// public static final int RESULT_CONNECT = 3;
+	// public static final int RESULT_TIMEOUT = 4;
+	// public static final int RESULT_RESPONSE_NULL= 6;
+	// public static final int RESULT_ERR_USERAUTH= 8;
+
+	// enum RES_VERIFYUSER{RESULT_FALSE,RESULT_TRUE,}
+	// public static int PROTOCAL_FALSE = 0;
+	// public static int PROTOCAL_TRUE = 1;
+	// public static int PROTOCAL_NOT_AUTH = 2;
+	// public static int PROTOCAL_SUCCESS = 1;
+	// public static int PROTOCAL_FAILED = 1;
+	// public static int PROTOCAL_MORE=4;
+	// public static int ERR_LOCALFILE = 0;
+
+	// static String URL_JSON_TEST = "http://192.168.23.1/xampp/json_test.php";
+	// static String URL_VERIFY_USER =
+	// "http://192.168.1.10/xampp/verify_user.php";
+	// static String URL_UPLOAD_PHOTO =
+	// "http://192.168.1.10/xampp/save_upload_file.php";
+	public static String URL_VERIFY_USER = "http://192.168.23.1/xampp/apex_user.php";
+	public static String URL_UPDATE_AUTH = "http://192.168.23.1/xampp/apex_auth.php";
+	public static String FAKE_URL_UPDATE_AUTH = "http://192.168.23.1/xampp/auth.json";
+	public static String FAKE_SEARCH = "http://192.168.23.1/xampp/recordset.json";
+
+	// static String URL_UPLOAD_PHOTO =
+	// "http://192.168.23.1/xampp/save_upload_file.php";
+
+	private static String fakegetJson(String url)
+	{
+		return download(url, 10000);
+		// return null;
+
+	}
+
+	public static String download(String urlStr, int timeout)
+	{
+		String TAG = "net_dbg@download";
+
+		Log.d(TAG, urlStr);
+
+		StringBuffer sb = new StringBuffer();
+		String line = null;
+		BufferedReader buffer = null;
+		HttpURLConnection urlConn = null;
+		try
+		{
+			// 创建一个URL对象
+			URL url = new URL(urlStr);
+			// 创建一个Http连接
+			urlConn = (HttpURLConnection) url.openConnection();
+
+			urlConn.setConnectTimeout(timeout);
+			urlConn.setReadTimeout(timeout);
+			// urlConn.connect();
+
+			int irespon = urlConn.getResponseCode();
+			if (irespon != HttpURLConnection.HTTP_OK)
+			{
+				Log.e(TAG, "HTTP ERROR CODE " + irespon + " url: " + urlStr);
+				urlConn.disconnect();
+				return null;
+			}
+
+			// 使用IO流读取数据
+			buffer = new BufferedReader(new InputStreamReader(
+					urlConn.getInputStream()));
+			while ((line = buffer.readLine()) != null)
+			{
+				sb.append(line);
+			}
+			Log.d(TAG, "download success @" + urlStr);
+		}
+		catch (MalformedURLException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		catch (IOException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		finally
+		{
+			try
+			{
+				if (urlConn != null)
+					urlConn.disconnect();
+				if (buffer != null)
+					buffer.close();
+			}
+			catch (Exception e)
+			{
+				e.printStackTrace();
+			}
+
+		}
+		return sb.toString();
+	}
+
+	public static String getJson(String url, Bundle parms)
+	{
+		String TAG = "net_dbg@GetJson";
+		Log.d(TAG, "entry");
+
+		if (true)
+			return fakegetJson(url);
+		try
+		{
+			BasicHttpParams httpParams = new BasicHttpParams();
+			HttpConnectionParams.setConnectionTimeout(httpParams,
+					REQUEST_TIMEOUT);
+			HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
+			HttpClient client = new DefaultHttpClient(httpParams);
+			HttpPost post = new HttpPost(url);
+			MultipartEntity reqEntity = new MultipartEntity(
+					HttpMultipartMode.BROWSER_COMPATIBLE);
+
+			Set<String> keys = parms.keySet();
+			for (String key : keys)
+			{
+				if (key.contains("_file"))
+				{
+					;
+				}
+				else
+					reqEntity.addPart(key, new StringBody(parms.get(key)
+							.toString()));
+
+			}
+
+			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();
+						// JSONObject obj = new JSONObject(sb.toString());
+						// if (obj.length() > 0)
+						// {
+						// // JSONObject obj = array.getJSONObject(0);
+						// try
+						// {
+						// int verifyresult = Integer.parseInt(obj
+						// .getString("result"));
+						// if (verifyresult == Network.AP_USER_AUTH)
+						// {
+						// return RESULT_TRUE;
+						// }
+						// else
+						// {
+						// return RESULT_FALSE;
+						// }
+						// }
+						// catch (Exception e)
+						// {
+						// Log.e(TAG, e.toString());
+						// return RESULT_ERROR;
+						// }
+						// }
+					}
+					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 VerifyUser(String user, String password)
+	// {
+	// String TAG = "net_dbg@VerifyUser";
+	// Log.d(TAG, "entry");
+	// try
+	// {
+	// BasicHttpParams httpParams = new BasicHttpParams();
+	// HttpConnectionParams.setConnectionTimeout(httpParams,
+	// REQUEST_TIMEOUT);
+	// HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
+	// HttpClient client = new DefaultHttpClient(httpParams);
+	// HttpPost post = new HttpPost(URL_VERIFY_USER);
+	// MultipartEntity reqEntity = new MultipartEntity(
+	// HttpMultipartMode.BROWSER_COMPATIBLE);
+	// reqEntity.addPart("user", new StringBody(user));
+	// reqEntity.addPart("password", new StringBody(password));
+	//
+	// 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 RESULT_NET_ERROR;
+	// }
+	// JSONObject obj = new JSONObject(sb.toString());
+	// if (obj.length() > 0)
+	// {
+	// // JSONObject obj = array.getJSONObject(0);
+	// try
+	// {
+	// int verifyresult = Integer.parseInt(obj
+	// .getString("result"));
+	// if (verifyresult == Network.AP_USER_AUTH)
+	// {
+	// return RESULT_TRUE;
+	// }
+	// else
+	// {
+	// return RESULT_FALSE;
+	// }
+	// }
+	// catch (Exception e)
+	// {
+	// Log.e(TAG, e.toString());
+	// return RESULT_ERROR;
+	// }
+	// }
+	// }
+	// catch (Exception e)
+	// {
+	// Log.e(TAG, e.toString());
+	// return RESULT_ERROR;
+	// // TODO: handle exception
+	// }
+	// finally
+	// {
+	// is.close();
+	//
+	// }
+	//
+	// }
+	// else
+	// {
+	// /*
+	// * resEntity is null
+	// */
+	// Log.d(TAG, "RESPONSE ENTITY IS NULL");
+	// return RESULT_NET_ERROR;
+	// }
+	//
+	// }
+	// 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 RESULT_ERROR;
+	// }
+	// catch (Exception e)
+	// {
+	// Log.e(TAG, e.toString());
+	// return RESULT_ERROR;
+	// // TODO: handle exception
+	// }
+	// finally
+	// {
+	// is.close();
+	//
+	// }
+	//
+	// }
+	// else
+	// {
+	// /*
+	// * resEntity is null
+	// */
+	// Log.e(TAG, "RESPONSE ENTITY IS NULL");
+	// return RESULT_NET_ERROR;
+	// }
+	// }
+	//
+	// }
+	// catch (ConnectTimeoutException e)
+	// {
+	// Log.d(TAG, "request time out");
+	// return RESULT_NET_ERROR;
+	//
+	// }
+	// catch (Exception e)
+	// {
+	// Log.d(TAG, e.toString());
+	// return RESULT_ERROR;
+	// }
+	// return RESULT_ERROR;
+	// }
+
+	// public static int UploadFile(String path, String user, String password,
+	// String pid)
+	// {
+	// String TAG = "net_dbg@VerifyUser";
+	// Log.d(TAG, "entry");
+	//
+	// Log.d(TAG, "sourcefile:" + path);
+	// File file = new File(path);
+	//
+	// if (file.exists() == false)
+	// return RESULT_LOCALFILE_ERROR;
+	//
+	// try
+	// {
+	// BasicHttpParams httpParams = new BasicHttpParams();
+	// HttpConnectionParams.setConnectionTimeout(httpParams,
+	// REQUEST_TIMEOUT);
+	// HttpConnectionParams.setSoTimeout(httpParams, SO_TIMEOUT);
+	// HttpClient client = new DefaultHttpClient(httpParams);
+	// HttpPost post = new HttpPost(URL_UPLOAD_PHOTO);
+	// MultipartEntity reqEntity = new MultipartEntity(
+	// HttpMultipartMode.BROWSER_COMPATIBLE);
+	// reqEntity.addPart("user", new StringBody(user));
+	// reqEntity.addPart("password", new StringBody(password));
+	// reqEntity.addPart("pid", new StringBody(pid));
+	// FileBody bin = new FileBody(file);
+	// reqEntity.addPart("imagefile", bin);
+	// 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 RESULT_NET_ERROR;
+	// }
+	// JSONObject obj = new JSONObject(sb.toString());
+	// if (obj.length() > 0)
+	// {
+	// // JSONObject obj = array.getJSONObject(0);
+	// try
+	// {
+	// int uploadresult = Integer.parseInt(obj
+	// .getString("result"));
+	// if (uploadresult == Network.AP_UPLOAD_SUCCESS)
+	// {
+	// return RESULT_TRUE;
+	// }
+	// else
+	// if (uploadresult == Network.AP_USER_NOT_AUTH)
+	// {
+	// Log.d(TAG, "RESULT_ERR_USERAUTH");
+	// return RESULT_USERAUTH_ERROR;
+	// }
+	// else
+	// {
+	// return RESULT_FALSE;
+	// }
+	// }
+	// catch (Exception e)
+	// {
+	// Log.e(TAG, e.toString());
+	// return RESULT_FALSE;
+	// }
+	// }
+	// }
+	// catch (Exception e)
+	// {
+	// Log.e(TAG, e.toString());
+	// return RESULT_ERROR;
+	// // TODO: handle exception
+	// }
+	// finally
+	// {
+	// is.close();
+	//
+	// }
+	//
+	// }
+	// else
+	// {
+	// /*
+	// * resEntity is null
+	// */
+	// Log.d(TAG, "RESPONSE ENTITY IS NULL");
+	// return RESULT_NET_ERROR;
+	// }
+	//
+	// }
+	// 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 RESULT_ERROR;
+	// }
+	// catch (Exception e)
+	// {
+	// Log.e(TAG, e.toString());
+	// return RESULT_ERROR;
+	// // TODO: handle exception
+	// }
+	// finally
+	// {
+	// is.close();
+	//
+	// }
+	//
+	// }
+	// else
+	// {
+	// /*
+	// * resEntity is null
+	// */
+	// Log.e(TAG, "RESPONSE ENTITY IS NULL");
+	// return RESULT_NET_ERROR;
+	// }
+	// }
+	//
+	// }
+	// catch (ConnectTimeoutException e)
+	// {
+	// Log.d(TAG, "request time out");
+	// return RESULT_NET_ERROR;
+	//
+	// }
+	// catch (Exception e)
+	// {
+	// Log.d(TAG, e.toString());
+	// return RESULT_ERROR;
+	// }
+	//
+	// return RESULT_FALSE;
+	//
+	// // try
+	// // {
+	// // HttpClient client = new DefaultHttpClient();
+	// // HttpPost post = new HttpPost(url);
+	// // MultipartEntity reqEntity = new MultipartEntity(
+	// // HttpMultipartMode.BROWSER_COMPATIBLE);
+	// // reqEntity.addPart("user", new StringBody(user));
+	// // reqEntity.addPart("password", new StringBody(password));
+	// // reqEntity.addPart("pid", new StringBody(pid));
+	// // FileBody bin = new FileBody(file);
+	// // reqEntity.addPart("imagefile", bin);
+	// // post.setEntity(reqEntity);
+	// // HttpResponse response = client.execute(post);
+	// // HttpEntity resEntity = response.getEntity();
+	// // if (resEntity != null)
+	// // {
+	// //
+	// // String result = EntityUtils.toString(resEntity);
+	// // Log.d(TAG, "Response:" + result);
+	// // return Integer.parseInt(result);
+	// // // if(Boolean.parseBoolean(result)==true)
+	// // // return true;
+	// // // else
+	// // // return false;
+	// // }
+	// //
+	// // }
+	// // catch (Exception e)
+	// // {
+	// // e.printStackTrace();
+	// // }
+	// // return 0;
+	// }
+	public static int get_Auth(String name, String password)
+	{
+
+		String TAG = "net_dbg@get_Auth";
+		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);
+		int ver = ApexTrackingApplication.get_instance()
+				.getSharedPreferences("Apex_auth", Context.MODE_PRIVATE)
+				.getInt("AuthInfoVer", 0);
+		parms.putString("auth_ver", ver + "");
+		String jstr = getJson(Network.FAKE_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);
+	}
+
+	private static int parse_authinfo(String json)
+	{
+		String TAG = "net_dbg@parse_authinfo";
+		// JSONArray array;
+		JSONObject jsobj;
+		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)
+				{
+					// user not authorized return
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return RESULT_FALSE;
+				}
+
+				JSONObject objheader = jsobj.getJSONObject("header");
+				// JSONObject objsessionid = jsobj.getJSONObject(1); // session
+				// id
+				// on
+				// server;
+				ApexTrackingApplication.put_sessionid(objheader
+						.getInt("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("Apex_auth", Context.MODE_PRIVATE)
+						.edit();
+
+				editor.putInt("AuthInfoVer", objheader.getInt("ver"));
+				JSONObject objfuncs = jsobj.getJSONObject("functions");
+				Iterator it = objfuncs.keys();
+				while (it.hasNext())
+				{
+					String key = (String) it.next();
+
+//					Set<String> funset = new HashSet<String>();
+					JSONObject objfun = objfuncs.getJSONObject(key);
+
+					editor.putString(key,objfun.toString());
+					// JSONArray arrfun = jsobj.get(i);
+					// JSONObject objname = arrfun.getJSONObject(0);
+					//
+//					funset.add(objfun.getString("name"));
+//					funset.add(objfun.getJSONObject("search").toString());
+//					funset.add(objfun.getJSONObject("result").toString());
+//					editor.putStringSet(objfun.getString("name"), funset);
+					// 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);
+					// }
+				}
+				// while (jsobj)
+				// for (int i = 4; i < jsobj.length(); i++) // get functions
+				// auth
+				// // info from server;
+				// {
+				// Set<String> funset = new HashSet<String>();
+				//
+				// JSONArray arrfun = jsobj.get(i);
+				// JSONObject objname = arrfun.getJSONObject(0);
+				//
+				// funset.add(objname.getString("name"));
+				// funset.add(jsobj.getJSONArray(1).toString());
+				// funset.add(jsobj.getJSONArray(2).toString());
+				// editor.putStringSet("function" + (i - 4), funset);
+				// }
+				editor.commit();
+				return RESULT_TRUE;
+			}
+			Log.d(TAG, "json is wrong");
+			return RESULT_USERAUTH_ERROR;
+		}
+		catch (JSONException e1)
+		{
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+			Log.d(TAG, "json is wrong");
+		}
+
+		// 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;
+	}
+}

+ 66 - 0
Apex/src/com/usai/util/SqlOpenHelper.java

@@ -0,0 +1,66 @@
+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;
+
+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) {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

+ 499 - 0
Apex/src/com/usai/util/dbUtil.java

@@ -0,0 +1,499 @@
+package com.usai.util;
+
+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.provider.ContactsContract;
+import android.telephony.PhoneNumberUtils;
+import android.util.Log;
+
+public class dbUtil
+{
+
+	// public static final String ZONECODE
+	// public static final int FILTER_TYPE_MSG = 0;
+	// public static final int FILTER_TYPE_BOTH = 1;
+	// public static final int FILTER_TYPE_CALL = 2;
+
+	// public static final int RECORD_TYPE_CALL = 2;
+	// public static final int RECORD_TYPE_MSG = 1;
+	//
+	// public static final int NUMBER_TYPE_NULL = 0;
+	// public static final int NUMBER_TYPE_NORMAL = 1;
+	// public static final int NUMBER_TYPE_BLACK = 2;
+	// public static final int NUMBER_TYPE_WHITE = 3;
+	// public static final int NUMBER_TYPE_GRAY = 4;
+	// public static final int NUMBER_TYPE_UNKNOWN = 7;
+
+	// public static final int NUMBER_TYPE_CONTACT = 5;
+	// public static final int NUMBER_TYPE_SUSPECT = 6;
+
+	// public static final int FILTER_SOURCE_BLACKLIST = 0;
+	// public static final int FILTER_SOURCE_SINGLERING = 1;
+	// public static final int FILTER_SOURCE_KEYWORDS = 2;
+	// public static final int FILTER_SOURCE_NONUMBER = 3;
+
+	// public static void AddNumberToBlacklist(Context context, String Number) {
+	// SQLiteDatabase db;
+	// db = dbUtil.OpenDB(context, null, true);
+	// boolean bexist = isRecordExist(db, "user_numberlist", "number = '"
+	// + Number + "'");
+	// if (bexist == false) {
+	// ContentValues cv = new ContentValues();
+	// cv.put("number", Number);
+	// cv.put("type", dbUtil.NUMBER_TYPE_BLACK);
+	// cv.put("burntype", 3);
+	// cv.put("cimm", PhoneNumberUtils.toCallerIDMinMatch(Number));
+	// db.insert("user_numberlist", null, cv);
+	// }
+	// dbUtil.CloseDB(db);
+	// }
+
+	// public static int KeywordsFilter(Context context, String Msg) {
+	// int ret = -1;
+	// boolean bKeywordsFilter = context.getSharedPreferences("PhoneAsstPref",
+	// 0).getBoolean("KeywordsFilterPref", false);
+	//
+	// // = context.getSharedPreferences("PhoneAsstPref", 0)
+	// // .getBoolean("BlockUnknownNumber", false);
+	// if (bKeywordsFilter == false)
+	// return ret;
+	// SQLiteDatabase db = dbUtil.OpenDB(context, null, true);
+	//
+	// Cursor cursor = null;
+	// try {
+	//
+	// cursor = db.query("user_keywords", new String[] { "_id", "words" },
+	// null, null, null, null, "level desc", null);
+	//
+	// while (cursor.moveToNext()) {
+	// String keywords = cursor.getString(1);
+	// String[] spliter = keywords.split(" ");
+	//
+	// if (spliter.length == 0)
+	// continue;
+	//
+	// int ifound = spliter.length; // 关键字个数
+	// for (int idx = 0; idx < spliter.length; idx++) {
+	// // 兼容以前版本关键字有多空格情况;
+	// if (spliter[idx].equals("")) {
+	// ifound--; // 排除误计算的空数量
+	// continue;
+	// }
+	//
+	// if (Msg.indexOf(spliter[idx]) != -1) {
+	// ifound--;
+	// }
+	// }
+	// if (ifound == 0) {
+	// int id = cursor.getInt(0);
+	// db.execSQL("update " + "user_keywords"
+	// + " set level = level+1 where _id=" + id);
+	// ret = id;
+	// break;// break while
+	// }
+	//
+	// }
+	// } catch (SQLiteException e) {
+	// dbgUtil.Log(Log.ERROR, "sql_err", e.toString());
+	// } finally {
+	// dbUtil.CloseCursor(cursor);
+	// dbUtil.CloseDB(db);
+	// }
+	// return ret;
+	// }
+
+	// public static final int NUMBER_TYPE_UNKNOWN = 5;//no number ,hide number
+	// ect;
+	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 int query_NumberType(SQLiteDatabase db, String number) {
+	// String cimm = PhoneNumberUtils.toCallerIDMinMatch(number);
+	// int ret = -1;
+	// Cursor cursor = db.query("user_numberlist", new String[] { "type",
+	// "number" }, "cimm = '" + cimm + "'", null, null, null, null);
+	// while (cursor.moveToNext()) {
+	// if (PhoneNumberUtils.compare(number, cursor.getString(1))) {
+	// dbgUtil.Log(
+	// Log.ERROR,
+	// "QUERY FROM user_numberlist",
+	// number + "=" + cursor.getString(1) + "type="
+	// + cursor.getInt(0));
+	// ret = cursor.getInt(0);
+	// break;
+	// }
+	// }
+	// CloseCursor(cursor);
+	// return ret;
+	// }
+
+	// static boolean isContact(Context context, String number) {
+	// // String cimm=PhoneNumberUtils.toCallerIDMinMatch(number);
+	// return dbUtil.isContentExist(context,
+	// // ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
+	// Uri.withAppendedPath(
+	// ContactsContract.PhoneLookup.CONTENT_FILTER_URI,
+	// Uri.encode(number)),
+	// // ContactsContract.CommonDataKinds.Phone.NUMBER + "= '" +
+	// // number+ "'");
+	// /* "min_match = '" + cimm+ "'" */null);
+	// }
+
+	// static boolean isSuspect(SQLiteDatabase db, String number) {
+	// return dbUtil.isRecordExist(db, "user_suspectlist", "number = '"
+	// + number + "'");
+	// }
+
+	// public static int get_CallNumberType_old(Context context,
+	// String incomingNumber)
+	// {
+	// int type = NUMBER_TYPE_NULL;
+	// SQLiteDatabase db = dbUtil.OpenDB(context, null, true);
+	//
+	// boolean bBlockUnknown = context
+	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
+	// "BlockUnknownNumber", false);
+	// boolean bignorcontact = context
+	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
+	// "IgnoreContact", false);
+
+	// if ((incomingNumber == null || incomingNumber.equals("")))
+	// if (bBlockUnknown)
+	// type = NUMBER_TYPE_BLACK;
+	// else
+	// type = NUMBER_TYPE_NORMAL;
+	// else
+	// {
+	// type = query_NumberType(db, incomingNumber);
+	// if (type == NUMBER_TYPE_WHITE)
+	// {
+	//
+	// }
+	// else
+	// if (bignorcontact && isContact(context, incomingNumber))
+	// {
+	// type = NUMBER_TYPE_CONTACT;
+	// dbgUtil.Log(Log.ERROR,null, "number type contact");
+	// }
+	// else
+	// if (type == NUMBER_TYPE_BLACK)
+	// {
+	// }
+	// else
+	// if (dbUtil.isRecordExist(db, "user_suspectlist",
+	// "number = '" + incomingNumber + "'"))
+	// {
+	// type = NUMBER_TYPE_SUSPECT;
+	// }
+	// else
+	// {
+	// type = NUMBER_TYPE_NORMAL;
+	//
+	// }
+	// }
+	// dbUtil.CloseDB(db);
+	//
+	// dbgUtil.Log(Log.ERROR,"get_CallNumberType",
+	// "number="+incomingNumber+" type="+type);
+	// return type;
+	//
+	// }
+
+	// public static NumberInfo get_NumberInfo(Context context,
+	// String incomingNumber)
+	// {
+	// NumberInfo numberInfo = new NumberInfo();
+	// numberInfo.incomingNumber = incomingNumber;
+	// SQLiteDatabase db = dbUtil.OpenDB(context, null, true);
+	//
+	// // boolean bBlockUnknown = context
+	// // .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
+	// // "BlockUnknownNumber", false);
+	// // boolean bignorcontact = context
+	// // .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
+	// // "IgnoreContact", false);
+	//
+	// // int type = NUMBER_TYPE_NULL;
+	// if (incomingNumber == null || incomingNumber.length() < 3)
+	// {
+	// numberInfo.BaseType = NUMBER_TYPE_UNKNOWN;
+	// }
+	// else
+	// {
+	// numberInfo.BaseType = query_NumberType(db, incomingNumber);
+	// if (numberInfo.BaseType == -1)// not in user_numberlist;
+	// {
+	// numberInfo.BaseType = NUMBER_TYPE_NORMAL;
+	//
+	// // else
+	// // if (isSuspect(db, incomingNumber))
+	// // {
+	// // type = NUMBER_TYPE_SUSPECT;
+	// //
+	// // }
+	// // else
+	// // {
+	// // type = NUMBER_TYPE_NORMAL;
+	// // }
+	// }
+	// if (isContact(context, incomingNumber))
+	// {
+	// numberInfo.isContact = true;
+	// // type = NUMBER_TYPE_CONTACT;
+	// }
+	// if (isSuspect(db, incomingNumber))
+	// {
+	// numberInfo.isSuspect = true;
+	//
+	// }
+	//
+	// // else
+	// // if (type == NUMBER_TYPE_BLACK)
+	// // {
+	// // if (isContact(context, incomingNumber))
+	// // {
+	// // type = NUMBER_TYPE_CONTACT;
+	// // }
+	// // }
+	// }
+	// dbUtil.CloseDB(db);
+	//
+	// dbgUtil.Log(Log.ERROR, "get_NumberInfo", "number=" + incomingNumber
+	// + " type=" + numberInfo.BaseType);
+	// return numberInfo;
+	//
+	// }
+
+	// public static int get_SmsNumberType(Context context, String
+	// incomingNumber)
+	// {
+	// SQLiteDatabase db = dbUtil.OpenDB(context, null, false);
+	//
+	// boolean bBlockUnknown = context
+	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
+	// "BlockUnknownNumber", false);
+	// boolean bignorcontact = context
+	// .getSharedPreferences("PhoneAsstPref", 0).getBoolean(
+	// "IgnoreContact", false);
+	//
+	// int type = NUMBER_TYPE_NULL;
+	// if ((incomingNumber == null || incomingNumber.equals("")))
+	// if (bBlockUnknown)
+	// type = NUMBER_TYPE_BLACK;
+	// else
+	// type = NUMBER_TYPE_NORMAL;
+	// else
+	// {
+	// type = query_NumberType(db, incomingNumber);
+	// if (type == NUMBER_TYPE_WHITE)
+	// {
+	//
+	// }
+	// else
+	// if (bignorcontact && isContact(context, incomingNumber))
+	// {
+	// type = NUMBER_TYPE_CONTACT;
+	// dbgUtil.Log(Log.ERROR, null, "number type contact");
+	// }
+	// else
+	// if (type == NUMBER_TYPE_BLACK)
+	// {
+	// }
+	// else
+	// {
+	// type = NUMBER_TYPE_NORMAL;
+	//
+	// }
+	// }
+	// dbUtil.CloseDB(db);
+	//
+	// return type;
+	//
+	// }
+
+	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, "test1.db",
+				factory, 1);
+		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))");
+
+		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, new String[] { "*" }, 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, new String[] { "_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;
+
+	}
+
+	// if(isTableEmpty(db,"block_records"))
+
+}

+ 114 - 0
Apex/src/com/usai/util/dbgUtil.java

@@ -0,0 +1,114 @@
+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 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/src/com/usai/util/package-info.java

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