Ray Zhang 12 vuotta sitten
vanhempi
commit
27e20c843e

+ 4 - 2
Apex/AndroidManifest.xml

@@ -38,7 +38,8 @@
 
         <activity
             android:name="com.usai.apex.DetailActivity"
-            android:label="@string/title_activity_detail" >
+            android:label="@string/title_activity_detail" 
+            android:screenOrientation="landscape">
             <meta-data
                 android:name="android.support.PARENT_ACTIVITY"
                 android:value="android.support.v4.app.FragmentActivity" />
@@ -102,7 +103,8 @@
         <activity
             android:name="com.usai.apex.HelpActivity"
             android:label="@string/title_activity_help"
-            android:theme="@android:style/Theme.Holo.NoActionBar" >
+            android:theme="@android:style/Theme.Holo.NoActionBar"
+            android:screenOrientation="portrait" >
         </activity>
     </application>
 

BIN
Apex/res/drawable/apexlogo_2.png


+ 14 - 0
Apex/res/drawable/bg_button.xml

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

BIN
Apex/res/drawable/help_result.jpg


+ 2 - 2
Apex/res/drawable/tablehead.xml

@@ -3,8 +3,8 @@
 
     <gradient
         android:angle="0"
-        android:endColor="@android:color/holo_blue_light"
-        android:startColor="@android:color/holo_blue_light" />
+        android:endColor="@android:color/holo_blue_dark"
+        android:startColor="@android:color/holo_blue_dark" />
 
     <stroke
         android:width="1dp"

+ 2 - 0
Apex/res/layout-hdpi/activity_function_select.xml

@@ -5,6 +5,7 @@
     android:layout_alignParentTop="true"
     android:layout_centerHorizontal="true"
     android:shrinkColumns="*"
+    android:stretchColumns="*"
     tools:context=".FunctionSelectActivity" >
 
     <TableRow
@@ -14,6 +15,7 @@
 
         <ImageButton
             android:id="@+id/ibtn_booking"
+
             android:src="@drawable/ic_oceanbooking" />
 
         <ImageButton

+ 7 - 5
Apex/res/layout/activity_function_select.xml

@@ -4,17 +4,19 @@
     android:layout_height="wrap_content"
     android:layout_alignParentTop="true"
     android:layout_centerHorizontal="true"
+    android:shrinkColumns="*"
+    android:stretchColumns="*"
     tools:context=".FunctionSelectActivity" >
 
     <TableRow
         android:id="@+id/tableRow3"
-        android:layout_width="wrap_content"
+        android:layout_width="fill_parent"
         android:layout_height="wrap_content" >
 
         <ImageButton
             android:id="@+id/ibtn_booking"
-            android:src="@drawable/ic_oceanbooking"
-            android:contentDescription="" />
+            android:contentDescription=""
+            android:src="@drawable/ic_oceanbooking" />
 
         <ImageButton
             android:id="@+id/ibtn_info"
@@ -27,7 +29,7 @@
 
     <TableRow
         android:id="@+id/tableRow4"
-        android:layout_width="wrap_content"
+        android:layout_width="fill_parent"
         android:layout_height="wrap_content" >
 
         <ImageButton
@@ -45,7 +47,7 @@
 
     <TableRow
         android:id="@+id/tableRow1"
-        android:layout_width="wrap_content"
+        android:layout_width="fill_parent"
         android:layout_height="wrap_content" >
 
         <ImageButton

+ 43 - 2
Apex/res/layout/activity_result.xml

@@ -73,7 +73,8 @@
             android:layout_height="wrap_content"
             android:layout_weight="1"
             style="@android:attr/buttonBarButtonStyle"
-            android:text="Pre Page" />
+            android:text="Pre Page" 
+            android:enabled="false"/>
 
         <Button
             android:id="@+id/btn_next"
@@ -90,7 +91,47 @@
         android:layout_height="wrap_content"
         android:layout_alignParentTop="true"
         android:layout_centerHorizontal="true"
-        android:text="aaa"
+        android:text="0 records"
         android:textAppearance="?android:attr/textAppearanceLarge" />
 
+    <LinearLayout
+        android:id="@+id/ll_refresh"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+       
+        android:layout_centerHorizontal="true"
+        android:layout_centerVertical="true"
+        android:orientation="vertical" 
+        android:gravity="center_horizontal"
+        android:visibility="invisible">
+
+        <TextView
+            android:id="@+id/textView1"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:gravity="center_horizontal"
+            android:text="Failed to get records\nTap Refresh button to retry" 
+            android:textAppearance="?android:attr/textAppearanceLarge" />
+            <Button
+                android:id="@+id/btn_refresh"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="10dp"
+
+                android:drawableLeft="@android:drawable/ic_popup_sync"
+                style="@android:attr/buttonBarButtonStyle"
+                android:text="Refresh" />
+     <!--    <FrameLayout
+            android:layout_width="wrap_content"
+            
+            android:layout_height="wrap_content"
+            android:background="@android:color/holo_blue_dark" 
+            android:layout_marginTop="10dp"> 
+
+
+
+        </FrameLayout>-->
+
+    </LinearLayout>
+
 </RelativeLayout>

+ 72 - 7
Apex/res/layout/detail_fragment.xml

@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content" >
 
-
-
-
-    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-        
+    <ScrollView
+        android:id="@+id/sl_root"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
@@ -15,8 +15,73 @@
             android:id="@+id/ll_root"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:orientation="vertical" 
-            android:background="@android:color/holo_blue_bright">
+            android:background="@android:color/holo_blue_bright"
+            android:orientation="vertical" >
+
+            <TextView
+                android:id="@+id/tv_empty"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center_horizontal"
+                android:text="No content in this page"
+                android:textAppearance="?android:attr/textAppearanceMedium"
+                android:visibility="gone" />
+
+            <LinearLayout
+                android:id="@+id/ll_refresh"
+                android:layout_width="fill_parent"
+                android:layout_height="wrap_content"
+                
+                android:gravity="center_horizontal"
+                android:orientation="vertical"
+                android:background="#FFF5F5F5"
+                android:visibility="gone" >
+
+                <TextView
+                    android:id="@+id/textView1"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:gravity="center_horizontal"
+                    android:text="Failed to get records\nTap Refresh button to retry"
+                    android:textAppearance="?android:attr/textAppearanceLarge" />
+
+                <Button
+                    android:id="@+id/btn_refresh"
+                    style="@android:attr/buttonBarButtonStyle"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="10dp"
+                    android:drawableLeft="@android:drawable/ic_popup_sync"
+                    android:text="Refresh" />
+            </LinearLayout>
         </LinearLayout>
     </ScrollView>
 
+    <RelativeLayout
+        android:id="@+id/status"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center"
+        android:orientation="vertical"
+        android:visibility="gone" >
+
+        <TextView
+            android:id="@+id/status_message"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_below="@+id/progressbar"
+            android:layout_centerHorizontal="true"
+            android:layout_marginBottom="16dp"
+            android:text="Loading..."
+            android:textAppearance="?android:attr/textAppearanceMedium" />
+
+        <ProgressBar
+            android:id="@+id/progressbar"
+            style="?android:attr/progressBarStyleLarge"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_centerInParent="true"
+            android:layout_marginTop="41dp" />
+    </RelativeLayout>
+
+</RelativeLayout>

+ 4 - 2
Apex/res/layout/keymapping_item.xml

@@ -1,14 +1,15 @@
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="wrap_content"
     android:orientation="horizontal" >
 
     <TextView
         android:id="@+id/tv_key"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="match_parent"
         android:text="Key"
+        android:gravity="center_vertical"
         android:layout_weight="1" 
         android:textStyle="bold"
         android:background="@drawable/detail_item"/>
@@ -17,6 +18,7 @@
         android:id="@+id/tv_value"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:gravity="center_vertical"
         android:text="Value" 
         android:layout_weight="1"
         android:background="@drawable/detail_item"/>

+ 1 - 1
Apex/res/layout/list_item.xml

@@ -5,7 +5,7 @@
 
     <TextView
         android:id="@+id/tv_item"
-        android:layout_width="wrap_content"
+        android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"

+ 4 - 0
Apex/res/layout/web_content.xml

@@ -2,6 +2,10 @@
 <WebView xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="match_parent" 
+    android:scrollbarFadeDuration="0"
+    android:fadeScrollbars="false"
+    android:focusable="true"
+    android:fastScrollEnabled="true"
     >
     
 

+ 5 - 2
Apex/res/menu/detail.xml

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

+ 6 - 1
Apex/res/menu/result.xml

@@ -5,5 +5,10 @@
         android:orderInCategory="100"
         android:showAsAction="never"
         android:title="@string/action_custom_fields"/>
-
+    <item
+        android:id="@+id/action_help"
+        android:orderInCategory="200"
+        android:showAsAction="ifRoom" 
+        android:icon="@android:drawable/ic_menu_help"
+        android:title="@string/action_help"/>
 </menu>

+ 1 - 1
Apex/res/values/strings.xml

@@ -9,7 +9,7 @@
     <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_apex">Apex</string>
     <string name="title_activity_direct_tracking">DirectTracking</string>
     <string name="title_activity_function_select">Apex</string>
     <string name="title_activity_test">TestActivity</string>

+ 7 - 7
Apex/src/com/usai/apex/ApexActivity.java

@@ -42,13 +42,13 @@ public class ApexActivity extends FragmentActivity /*
 		setupTabs();
 	}
 
-	@Override
-	public boolean onCreateOptionsMenu(Menu menu)
-	{
-		// Inflate the menu; this adds items to the action bar if it is present.
-		getMenuInflater().inflate(R.menu.apex, menu);
-		return true;
-	}
+//	@Override
+//	public boolean 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()
 	{

+ 56 - 36
Apex/src/com/usai/apex/DetailActivity.java

@@ -2,12 +2,16 @@ package com.usai.apex;
 
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 
 import com.usai.util.commonUtil;
 
+import android.R.integer;
 import android.os.Bundle;
+import android.util.Log;
 import android.view.KeyEvent;
 import android.view.Menu;
+import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.FrameLayout;
@@ -22,7 +26,12 @@ public class DetailActivity extends FragmentActivity implements
 {
 	// int radomid = 1 + (int) (Math.random() * 15);
 	TabHost mTabHost;
-	HashMap<String, Integer> tabmap = new HashMap<String, Integer>();
+	LinkedHashMap<String, Integer> tabmap = new LinkedHashMap<String, Integer>();
+
+	// HashMap<String, DetailFragment> fragments = new HashMap<String,
+	// DetailFragment>();
+	String function_name;
+	String _id;
 
 	@Override
 	protected void onCreate(Bundle savedInstanceState)
@@ -31,56 +40,67 @@ public class DetailActivity extends FragmentActivity implements
 
 		setContentView(R.layout.activity_detail);
 
-		if (getIntent().getBooleanExtra("Detail", true))
-			tabmap.put("Detail", commonUtil.generateViewId());
-		if (getIntent().getBooleanExtra("Tracking", false))
-			tabmap.put("Tracking", commonUtil.generateViewId());
-		if (getIntent().getBooleanExtra("AMS LOG", false))
-			tabmap.put("AMS LOG", commonUtil.generateViewId());
-		if (getIntent().getBooleanExtra("ISF LOG", false))
-			tabmap.put("ISF LOG", commonUtil.generateViewId());
-
-		// final TabHost tabHost = getTabHost();
-		// mTabHost = (TabHost) findViewById(R.id.tabhost);
-
+		int count = getIntent().getIntExtra("actions_count", 0);
+		for (int i = 0; i < count; i++)
+		{
+			tabmap.put(getIntent().getStringExtra("action" + i),
+					commonUtil.generateViewId());
+		}
+		function_name = getIntent().getStringExtra("function_name");
+		_id = getIntent().getStringExtra("_id");
 		setupTabs();
 
 	}
 
+	// @Override
+	// protected void onSaveInstanceState(Bundle outState)
+	// {
+	// Iterator<String> iter=fragments.keySet().iterator();
+	//
+	// while (iter.hasNext())
+	// {
+	// String tag = (String) iter.next();
+	// getSupportFragmentManager().putFragment(outState,tag,fragments.get(tag));
+	//
+	// }
+	// outState.putStringArray("tags", fragments.keySet().toArray(new
+	// String[0]));
+	// Log.d("onSaveInstanceState","save fragments" +
+	// fragments.keySet().size());
+	// super.onSaveInstanceState(outState);
+	// }
+	//
+	// @Override
+	// protected void onRestoreInstanceState(Bundle savedInstanceState)
+	// {
+	// String [] tags =savedInstanceState.getStringArray("tags");
+	// Log.d("onRestoreInstanceState","load fragments" + tags.length);
+	// for(int i=0;i<tags.length;i++)
+	// {
+	// Log.d("onRestoreInstanceState","load fragment" + tags[i]);
+	// fragments.put(tags[i],(DetailFragment)
+	// getSupportFragmentManager().getFragment(savedInstanceState,tags[i]));
+	// }
+	//
+	// super.onRestoreInstanceState(savedInstanceState);
+	// }
+
 	/** {@inheritDoc} */
 	public View createTabContent(String tag)
 	{
-		// final TextView tv = new TextView(this);
-		// tv.setText("Content for tab with tag " + tag);
 		FrameLayout fl = new FrameLayout(this);
 		fl.setId(tabmap.get(tag));
 
 		Fragment f;
 		Bundle bundle = new Bundle();
-		bundle.putSerializable("type", "tag");
-		
-		if (tag.equals("Detail"))
-			f = new DetailFragment();
-		else
-			if (tag.equals("Tracking"))
-				f = new StatusFragment();
-			else
-				if (tag.equals("AMS LOG"))
-				{
-					f = new CBPFragment();
+		bundle.putString("action_type", tag);
+		bundle.putString("id", _id);
+		bundle.putString("module_name", function_name);
 
-				}
-				else
-					/* if(tag.equals("AMS LOG")) */
-					f = new CBPFragment();
+		Log.d("createTabContent", "create fragment" + tag);
+		f = new DetailFragment();
 
 		f.setArguments(bundle);
-		// Fragment loginFragment = new LoginFragment();
-		// Fragment dtFragement = new DirectTrackingFragment();
-		// Fragment slFragment = new ServiceLocationFragment();
-		// Add the fragment to the activity, pushing this transaction
-		// on to the back stack.
-
 		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
 		ft.replace(fl.getId(), f);
 		ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);

+ 352 - 70
Apex/src/com/usai/apex/DetailFragment.java

@@ -1,84 +1,183 @@
 package com.usai.apex;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import org.json.JSONException;
 import org.json.JSONObject;
 
+import com.usai.util.Network;
 import com.usai.util.commonUtil;
 
-import android.content.res.AssetManager;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.os.AsyncTask;
+import android.os.Build;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
+import android.text.Html;
 import android.util.Log;
 import android.util.SparseIntArray;
+import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.webkit.WebView;
+import android.widget.Button;
 import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
+import android.widget.ScrollView;
 import android.widget.TextView;
+import android.widget.Toast;
 
-public class DetailFragment extends Fragment implements OnClickListener
+public class DetailFragment extends Fragment implements OnClickListener /*
+																		 * ,
+																		 * OnGestureListener
+																		 */
 {
-	LinearLayout ll_root;
-	String mimeType = "text/html";
-	
-	SparseIntArray control = new SparseIntArray() ;
-//	HashMap<Integer, Integer> control = new HashMap<Integer, Integer>() ;
+	/* private GestureDetector mGestureDetector; */
+	@Override
+	public void onCreate(Bundle savedInstanceState)
+	{
+		// TODO Auto-generated method stub
+		super.onCreate(savedInstanceState);
+
+	}
 
 	@Override
-	public View onCreateView(LayoutInflater inflater, ViewGroup container,
-			Bundle savedInstanceState)
+	public void onDestroyView()
 	{
-		View view = inflater.inflate(R.layout.detail_fragment, null);
+		Log.d("DetailFragment", "onDestroyView()");
+		super.onDestroyView();
+	}
 
-		ll_root = (LinearLayout) view.findViewById(R.id.ll_root);
+	public String get_content()
+	{
+		return fragment_content;
+	}
 
-		// TextView tv= new TextView(getActivity());
-		// tv.setText("test12345");
-		//
-		// ll_root.addView(tv);
+	LinearLayout ll_root;
+	ScrollView sl_root;
+	String mimeType = "text/html";
+	private SearchTask m_task = null;
+	SparseIntArray control = new SparseIntArray();
+	// private TextView mStatusMessageView;
+	private View mStatusView;
+	String fragment_content = null;
 
-		String jstr = null;
-		AssetManager am = null;
-		am = getActivity().getAssets();
-		try
+	public void requestdata()
+	{
+
+		if (m_task != null)
 		{
-			String TAG = "DetailFragment fake json";
-			InputStream is = am.open("detail.json");
-
-			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");
-			}
+			return;
+		}
+		if (fragment_content != null)
+			return;
+		// mStatusMessageView.setText("Loading");
+		showProgress(true);
+		m_task = new SearchTask();
+		m_task.execute();
 
-			Log.d(TAG, "Response: content begin");
-			Log.d(TAG, sb.toString());
-			Log.d(TAG, "Response: content end");
+	}
 
-			if (sb.length() <= 0)
-			{
+	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);
 
-				jstr = null;
-			}
-			jstr = sb.toString();
+			mStatusView.setVisibility(View.VISIBLE);
+			mStatusView.animate().setDuration(shortAnimTime)
+					.alpha(show ? 1 : 0)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							mStatusView.setVisibility(show ? View.VISIBLE
+									: View.INVISIBLE);
+						}
+					});
+
+			ll_root.setVisibility(View.VISIBLE);
+			ll_root.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
+					.setListener(new AnimatorListenerAdapter()
+					{
+						@Override
+						public void onAnimationEnd(Animator animation)
+						{
+							ll_root.setVisibility(show ? View.INVISIBLE
+									: View.VISIBLE);
+						}
+					});
 		}
-		catch (IOException e)
+		else
 		{
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			// The ViewPropertyAnimator APIs are not available, so simply show
+			// and hide the relevant UI components.
+			mStatusView.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
+			ll_root.setVisibility(show ? View.INVISIBLE : View.VISIBLE);
 		}
+	}
 
-		init(jstr, inflater);
+	@Override
+	public View onCreateView(LayoutInflater inflater, ViewGroup container,
+			Bundle savedInstanceState)
+	{
+		/* mGestureDetector = new GestureDetector(this); */
+		View view = inflater.inflate(R.layout.detail_fragment, null);
+		sl_root = (ScrollView) view.findViewById(R.id.sl_root);
+		/*
+		 * sl_root.setOnTouchListener(new View.OnTouchListener() {
+		 * 
+		 * @Override public boolean onTouch(View v, MotionEvent event) { return
+		 * mGestureDetector.onTouchEvent(event); } });
+		 */
+		ll_root = (LinearLayout) view.findViewById(R.id.ll_root);
+		mStatusView = view.findViewById(R.id.status);
+		// TextView tv= new TextView(getActivity());
+		// tv.setText("test12345");
+		//
+		// ll_root.addView(tv);
+
+		// String jstr = null;
+		// AssetManager am = null;
+		// am = getActivity().getAssets();
+		// try
+		// {
+		// String TAG = "DetailFragment fake json";
+		// InputStream is = am.open("detail.json");
+		//
+		// 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)
+		// {
+		//
+		// jstr = null;
+		// }
+		// jstr = sb.toString();
+		// }
+		// catch (IOException e)
+		// {
+		// // TODO Auto-generated catch block
+		// e.printStackTrace();
+		// }
+		//
+		// init(jstr, inflater);
 		// String url = "<a href='http://www.google.com'>A1401330351H.pdf</a>";
 
 		// String
@@ -96,16 +195,41 @@ public class DetailFragment extends Fragment implements OnClickListener
 		//
 		// wv = (WebView) view.findViewById(R.id.webView1);
 		// wv.loadData(url1, mimeType, null);
+		LinearLayout ll = (LinearLayout) view.findViewById(R.id.ll_refresh);
+		Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
+		btn_refresh.setOnClickListener(new View.OnClickListener()
+		{
 
+			@Override
+			public void onClick(View v)
+			{
+				LinearLayout ll = (LinearLayout) ll_root
+						.findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.GONE);
+
+				requestdata();
+
+			}
+		});
+		requestdata();
 		return view;
 	}
 
 	void init(String jstr, LayoutInflater inflater)
 	{
+		String TAG = "init@DetailFragment";
+		Log.d(TAG, jstr);
 		try
 		{
 			JSONObject jsonObj = new JSONObject(jstr);
 			int group_count = jsonObj.getInt("count");
+			if (group_count == 0)
+			{
+
+				TextView tv_empty = (TextView) ll_root
+						.findViewById(R.id.tv_empty);
+				tv_empty.setVisibility(View.VISIBLE);
+			}
 			for (int i = 0; i < group_count; i++)
 			{
 				// String key = (String) it.next();
@@ -114,14 +238,14 @@ public class DetailFragment extends Fragment implements OnClickListener
 				JSONObject groupobj = jsonObj.getJSONObject("group" + i);
 				View v = inflater.inflate(R.layout.group_tag, null);
 				v.setOnClickListener(this);
-			
+
 				TextView tvgroup = (TextView) v.findViewById(R.id.tv_group);
 				String group_name = groupobj.getString("_name");
 				tvgroup.setText(group_name);
 				v.setId(commonUtil.generateViewId());
 				ll_root.addView(v);
 				String grouptype = groupobj.getString("_type");
-//				groupobj.remove("_type");
+				// groupobj.remove("_type");
 				if (grouptype.equals("mapping"))
 				{
 					LinearLayout mappingview = (LinearLayout) inflater.inflate(
@@ -130,12 +254,12 @@ public class DetailFragment extends Fragment implements OnClickListener
 					control.put(v.getId(), mappingview.getId());
 					ll_root.addView(mappingview);
 
-					int map_count = groupobj.getInt("_count");
-					for(int j=0;j<map_count;j++)
+					int map_count = groupobj.getInt("count");
+					for (int j = 0; j < map_count; j++)
 					{
-//						String keygroup = (String) itgroup.next();
-						JSONObject itemobj= groupobj.getJSONObject("item"+j);
-						String key = (String)itemobj.keys().next();
+						// String keygroup = (String) itgroup.next();
+						JSONObject itemobj = groupobj.getJSONObject("item" + j);
+						String key = (String) itemobj.keys().next();
 						String val = itemobj.getString(key);
 						LinearLayout mappingitem = (LinearLayout) inflater
 								.inflate(R.layout.keymapping_item, null);
@@ -145,16 +269,16 @@ public class DetailFragment extends Fragment implements OnClickListener
 						// tvkey.setBackgroundResource(R.drawable.detail_item);
 						TextView tvval = (TextView) mappingitem
 								.findViewById(R.id.tv_value);
-						tvval.setText(val);
+						tvval.setText(Html.fromHtml(val));
 						// tvval.setBackgroundResource(R.drawable.detail_item);
-						mappingview.addView(mappingitem);	
+						mappingview.addView(mappingitem);
 					}
-//					Iterator itgroup = groupobj.keys();
-//					while (itgroup.hasNext())
-//					{
-//					
-//
-//					}
+					// Iterator itgroup = groupobj.keys();
+					// while (itgroup.hasNext())
+					// {
+					//
+					//
+					// }
 				}
 				else
 					if (grouptype.equals("table"))
@@ -164,10 +288,28 @@ public class DetailFragment extends Fragment implements OnClickListener
 
 						wv = (WebView) inflater.inflate(R.layout.web_content,
 								null);
+
+						wv.getSettings().setDefaultTextEncodingName("UTF-8");
 						wv.setId(commonUtil.generateViewId());
 						control.put(v.getId(), wv.getId());
 						wv.loadData(content, mimeType, null);
+
+						// wv.setOnTouchListener(new OnTouchListener()
+						// {
+						// @Override
+						// public boolean onTouch(View v, MotionEvent event)
+						// {
+						//
+						// if (event.getAction() == MotionEvent.ACTION_UP)
+						// sl_root.requestDisallowInterceptTouchEvent(false);
+						// else
+						// sl_root.requestDisallowInterceptTouchEvent(true);
+						//
+						// return false;
+						// }
+						// });
 						ll_root.addView(wv);
+						Log.d("table content", content);
 
 					}
 				if (grouptype.equals("list"))
@@ -177,7 +319,7 @@ public class DetailFragment extends Fragment implements OnClickListener
 					listview.setId(commonUtil.generateViewId());
 					control.put(v.getId(), listview.getId());
 					ll_root.addView(listview);
-					long list_count = groupobj.getInt("_count");
+					long list_count = groupobj.getInt("count");
 					for (int j = 0; j < list_count; j++)
 					{
 						RelativeLayout listitem = (RelativeLayout) inflater
@@ -185,19 +327,19 @@ public class DetailFragment extends Fragment implements OnClickListener
 
 						TextView tvitem = (TextView) listitem
 								.findViewById(R.id.tv_item);
-						String val=groupobj.getString("line"+j);
+						String val = groupobj.getString("line" + j);
 						tvitem.setText(val);
 						// tvitem.setBackgroundResource(R.drawable.detail_item);
 						listitem.removeView(tvitem);
 
 						listview.addView(tvitem);
 					}
-//					Iterator itgroup = groupobj.keys();
-//					while (itgroup.hasNext())
-//					{
-//						String keygroup = (String) itgroup.next();
-//
-//					}
+					// Iterator itgroup = groupobj.keys();
+					// while (itgroup.hasNext())
+					// {
+					// String keygroup = (String) itgroup.next();
+					//
+					// }
 				}
 				// String value = obj.getString(key);
 				// JSONArray array = obj.getJSONArray(key);
@@ -229,6 +371,146 @@ public class DetailFragment extends Fragment implements OnClickListener
 			view.setVisibility(View.GONE);
 		else
 			view.setVisibility(View.VISIBLE);
-		
+
+	}
+
+	class SearchTask extends AsyncTask<Void, Void, Boolean>
+	{
+		int errorcode;
+
+		@Override
+		protected Boolean doInBackground(Void... params)
+		{
+			if (!Network.NetworkIsAvailable())
+
+			{
+				errorcode = Network.RESULT_NET_NOTAVAILABLE;
+				return false;
+			}
+			String jstr = Network.get_detail(getArguments());
+			if (jstr == null || jstr.length() <= 0)
+			{
+				// Log.d(TAG, "json is wrong");
+
+				errorcode = Network.RESULT_NET_ERROR;
+				return false;
+			}
+
+			fragment_content = jstr;
+			errorcode = Network.RESULT_TRUE;
+
+			return true;
+		}
+
+		@Override
+		protected void onPostExecute(Boolean success)
+		{
+			Log.i("onPostExecute", "entry");
+			m_task = null;
+			showProgress(false);
+
+			switch (errorcode)
+			{
+			case Network.RESULT_NET_NOTAVAILABLE:
+			{
+				Toast toast = Toast.makeText(
+						ApexTrackingApplication.get_instance(),
+						getText(R.string.msg_connection_none),
+						Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				break;
+			}
+			case Network.RESULT_NET_ERROR:
+			{
+				Toast toast = Toast.makeText(
+						ApexTrackingApplication.get_instance(),
+						getText(R.string.msg_net_error), Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				break;
+			}
+			case Network.RESULT_ERROR:
+			// case Network.RESULT_RESPONSE_NULL:
+			{
+				Toast toast = Toast.makeText(
+						ApexTrackingApplication.get_instance(),
+						getText(R.string.msg_net_resulterror),
+						Toast.LENGTH_LONG);
+				toast.setGravity(Gravity.CENTER, 0, 0);
+				toast.show();
+				break;
+			}
+
+			default:
+				break;
+			}
+
+			if (success)
+			{
+
+				init(fragment_content, getActivity().getLayoutInflater());
+			}
+			else
+			{
+				LinearLayout ll = (LinearLayout) ll_root.findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.VISIBLE);
+			}
+			super.onPostExecute(success);
+		}
+
+		@Override
+		protected void onCancelled()
+		{
+			m_task = null;
+			showProgress(false);
+		}
 	}
+	//
+	// @Override
+	// public boolean onDown(MotionEvent e)
+	// {
+	// // TODO Auto-generated method stub
+	// return false;
+	// }
+	//
+	// @Override
+	// public void onShowPress(MotionEvent e)
+	// {
+	// // TODO Auto-generated method stub
+	//
+	// }
+	//
+	// @Override
+	// public boolean onSingleTapUp(MotionEvent e)
+	// {
+	// // TODO Auto-generated method stub
+	// return false;
+	// }
+	//
+	// @Override
+	// public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
+	// float distanceY)
+	// {
+	// Log.e("onScroll",".................");
+	// Log.d("onScroll","dx:"+(e1.getX()-e2.getX()));
+	// Log.d("onScroll","dy:"+(e1.getY()-e2.getY()));
+	//
+	// return false;
+	// }
+	//
+	// @Override
+	// public void onLongPress(MotionEvent e)
+	// {
+	// // TODO Auto-generated method stub
+	//
+	// }
+	//
+	// @Override
+	// public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
+	// float velocityY)
+	// {
+	// Log.e("onFling",".................");
+	// return false;
+	// }
 }

+ 2 - 0
Apex/src/com/usai/apex/HelpActivity.java

@@ -22,6 +22,8 @@ public class HelpActivity extends Activity implements OnClickListener
 			iv.setImageResource(R.drawable.help_fields);
 		else if(caller.equals("search"))
 			iv.setImageResource(R.drawable.help_search);
+		else if(caller.equals("result"))
+			iv.setImageResource(R.drawable.help_result);
 	}
 	
 	

+ 120 - 158
Apex/src/com/usai/apex/ResultActivity.java

@@ -18,6 +18,8 @@ import android.animation.Animator;
 import android.animation.AnimatorListenerAdapter;
 import android.app.Activity;
 import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.util.Log;
@@ -31,6 +33,7 @@ import android.view.ContextMenu.ContextMenuInfo;
 import android.view.View.OnCreateContextMenuListener;
 import android.widget.AdapterView.AdapterContextMenuInfo;
 import android.widget.Button;
+import android.widget.LinearLayout;
 import android.widget.TableLayout;
 import android.widget.TableRow;
 import android.widget.TextView;
@@ -42,14 +45,14 @@ public class ResultActivity extends Activity
 	String password = null;
 	String function_name = null;
 	private SearchTask m_task = null;
-	
+
 	int sel = -1;
 
 	Bundle searchParms = null;
 	SearchResult searchresult = new SearchResult();
 
-	SparseArray< String> showfieldmap = new SparseArray< String>();
-//	HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
+	SparseArray<String> showfieldmap = new SparseArray<String>();
+	// HashMap<Integer, String> showfieldmap = new HashMap<Integer, String>();
 	private TextView mStatusMessageView;
 	// private View mSearchFormView;
 	private View footview;
@@ -80,11 +83,13 @@ public class ResultActivity extends Activity
 			{
 				// TextView tv_head = (TextView) findViewById(R.id.tv_head);
 
-				searchresult.set_direction(1);
+				// searchresult.set_direction(1);
 				if (searchresult.get_totalcount() == -1)
 					requestdata(true);
 				else
 				{
+					// if (searchresult.get_direction() == -1)
+					searchresult.set_offset(searchresult.get_offset() + 10);
 					requestdata(false);
 				}
 
@@ -99,11 +104,12 @@ public class ResultActivity extends Activity
 			public void onClick(View v)
 			{
 				// TextView tv_head = (TextView) findViewById(R.id.tv_head);
-				searchresult.set_direction(-1);
+				// searchresult.set_direction(-1);
 				if (searchresult.get_totalcount() == -1)
 					requestdata(true);
 				else
 				{
+					searchresult.set_offset(searchresult.get_offset() - 10);
 					requestdata(false);
 				}
 
@@ -111,6 +117,50 @@ public class ResultActivity extends Activity
 		});
 		mStatusView = findViewById(R.id.status);
 		mStatusMessageView = (TextView) findViewById(R.id.status_message);
+		LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
+		Button btn_refresh = (Button) ll.findViewById(R.id.btn_refresh);
+		btn_refresh.setOnClickListener(new View.OnClickListener()
+		{
+
+			@Override
+			public void onClick(View v)
+			{
+				LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.INVISIBLE);
+				if (searchresult.get_totalcount() == -1)
+					requestdata(true);
+				else
+					requestdata(false);
+
+			}
+		});
+
+		SharedPreferences RunOnce = getSharedPreferences("Apex", 0);
+
+		String vername;
+		try
+		{
+			vername = getPackageManager().getPackageInfo("com.usai.apex", 0).versionName;
+			boolean bFirstRun = RunOnce.getBoolean("FirstRun" + vername
+					+ "_result", true);
+			if (bFirstRun)
+			{
+				SharedPreferences.Editor editor = RunOnce.edit();
+				editor.putBoolean("FirstRun" + vername + "_result", false);
+				// Don't forget to commit your edits!!!
+				editor.commit();
+				Intent intent = new Intent();
+				intent.setClass(this, HelpActivity.class);
+				intent.putExtra("caller", "result");
+				startActivity(intent);
+
+			}
+		}
+		catch (NameNotFoundException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 		initTable();
 		requestdata(true);
 
@@ -138,70 +188,34 @@ public class ResultActivity extends Activity
 	@Override
 	public boolean onContextItemSelected(MenuItem item)
 	{
-		//		menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
-		Log.d("table row select", sel+ "");
-		
-	
+		// menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
+		// Log.d("table row select", sel+ "");
+
 		Intent intent = new Intent();
 		intent.setClass(this, DetailActivity.class);
-		intent.putExtra("Detail", true);
-		intent.putExtra("Tracking", true);
-		intent.putExtra("AMS LOG", true);
+
+		SQLiteDatabase db = dbUtil.OpenDB(this, null, false);
+		Cursor cursor = db.query("actions_info",
+				new String[] { "name", "_id" }, "function_name='"
+						+ function_name + "' and user='" + user + "'", null,
+				null, null, null, null);
+		int i = 0;
+		while (cursor.moveToNext())
+		{
+			String name = cursor.getString(0);
+			Log.d("actionname", name);
+			intent.putExtra("action" + i, name);
+			i++;
+		}
+		intent.putExtra("function_name", function_name);
+		intent.putExtra("actions_count", i);
+		intent.putExtra("_id", searchresult.get_record(sel).get("_id")
+				.toString());
+		dbUtil.CloseCursor(cursor);
+		dbUtil.CloseDB(db);
+
 		startActivity(intent);
-		// Cursor cursor = (Cursor) m_ListView
-		// .getItemAtPosition(menuInfo.position);
-		//
-		// switch (item.getItemId())
-		// {
-		// case 0:
-		// {// remove a record
-		// int idx = cursor.getColumnIndex("number");
-		// String strNumber = cursor.getString(idx);
-		// String whereclause = "number = '" + strNumber + "'";
-		// dbUtil.removeRecords(m_db, "user_numberlist", whereclause);
-		// RefreshList();
-		// // m_listadapter.notifyDataSetChanged();
-		// // this.getListAdapter().notif
-		// break;
-		// }
-		// // case 1:
-		// // {
-		// // //edit a record;
-		// //
-		// // int idx = cursor.getColumnIndex("_id");
-		// // int id = cursor.getInt(idx);
-		// //
-		// // Intent intent = new Intent();
-		// // intent.setClass(this, ActivityNumberListEdit.class);
-		// // NumberEditInfo EditInfo = new NumberEditInfo();
-		// // EditInfo.EditType = NumberEditInfo.TYPE_EDIT;
-		// // EditInfo.EditTableName = m_Activityinfo.TableName;
-		// //
-		// // EditInfo.EditRecordID =id;
-		// // if (m_Activityinfo.TableName == "user_blacklist")
-		// // {
-		// // // deal with black list;
-		// // EditInfo.EditTable = NumberEditInfo.EDIT_TABLE_BLACK;
-		// // EditInfo.CheckTableName = "user_whitelist";
-		// // EditInfo.LabelTextID = R.string.label_AddBlack;
-		// // EditInfo.NumberExistMoveID = R.string.phrase_numexist_white_mov;
-		// // EditInfo.NumberExistID = R.string.phrase_numexist_blk;
-		// // }
-		// // else
-		// // {
-		// // // deal with white list;
-		// // EditInfo.EditTable = NumberEditInfo.EDIT_TABLE_WHITE;
-		// // EditInfo.CheckTableName = "user_blacklist";
-		// // EditInfo.LabelTextID = R.string.label_AddWhite;
-		// // EditInfo.NumberExistMoveID = R.string.phrase_numexist_blk_mov;
-		// // EditInfo.NumberExistID = R.string.phrase_numexist_white;
-		// // }
-		// // intent.putExtra("ActivityInfo", EditInfo);
-		// //
-		// // startActivity(intent);
-		// // break;
-		// // }
-		// }
+
 		return super.onContextItemSelected(item);
 	}
 
@@ -278,10 +292,11 @@ public class ResultActivity extends Activity
 	@Override
 	public boolean onOptionsItemSelected(MenuItem item)
 	{
+		Intent intent = new Intent();
 		switch (item.getItemId())
 		{
 		case R.id.action_custom_fields:
-			Intent intent = new Intent();
+
 			intent.setClass(this, CustomizeFieldsActivity.class);
 			intent.putExtra("user", user);
 			// intent.putExtra("password", password);
@@ -289,7 +304,15 @@ public class ResultActivity extends Activity
 			intent.putExtra("behavior", Network.BEHAVIOR_RESULT);
 			startActivity(intent);
 			break;
-
+		case R.id.action_help:
+			// Intent intent = new Intent();
+			intent.setClass(this, HelpActivity.class);
+			intent.putExtra("caller", "result");
+			// // intent.putExtra("password", password);
+			// intent.putExtra("function_name", function_name);
+			// intent.putExtra("behavior", Network.BEHAVIOR_SEARCH);
+			startActivity(intent);
+			break;
 		default:
 			break;
 		}
@@ -400,8 +423,8 @@ public class ResultActivity extends Activity
 				}
 			}
 
-			if (searchresult.get_direction() == -1)
-				searchresult.set_offset(searchresult.get_offset() - 20);
+			// if (searchresult.get_direction() == -1)
+			// searchresult.set_offset(searchresult.get_offset() - 20);
 			searchParms.putString("offset", searchresult.get_offset() + "");
 
 			String jstr = Network.get_records(user, password, searchParms);
@@ -492,6 +515,7 @@ public class ResultActivity extends Activity
 				if (totalcount == 0)
 				{
 					tv_head.setText("0 record found");
+
 					return;
 				}
 				else
@@ -503,7 +527,7 @@ public class ResultActivity extends Activity
 
 				tl.removeViews(1, tl.getChildCount() - 1);
 				// int newcount = loadcount - showcount + 1;// +1 header row
-				for (int i = 0; i < 10; i++)
+				for (int i = 0; i < searchresult.get_recordscount(); i++)
 				{
 
 					TableRow recordRow = new TableRow(ResultActivity.this);
@@ -518,9 +542,10 @@ public class ResultActivity extends Activity
 									// v.setBackgroundColor(Color.GRAY);
 									// v.showContextMenu();
 									// return true;
-									TableRow tr = (TableRow)v;
-									TextView tvno=(TextView)tr.getChildAt(0);
-									sel=Integer.parseInt(tvno.getText().toString());
+									TableRow tr = (TableRow) v;
+									TextView tvno = (TextView) tr.getChildAt(0);
+									sel = Integer.parseInt(tvno.getText()
+											.toString()) % 10;
 									registerForContextMenu(v);
 									openContextMenu(v);
 									unregisterForContextMenu(v);
@@ -537,9 +562,8 @@ public class ResultActivity extends Activity
 					HashMap<String, String> record = searchresult.get_record(i);
 					TextView field = new TextView(ResultActivity.this);
 					field.setBackgroundResource(R.drawable.tableitem);
-					field.setText(searchresult.get_offset() - 10 + i + "");
-					Log.d("offset=" + searchresult.get_offset(), "direction="
-							+ searchresult.get_direction());
+					field.setText(searchresult.get_offset() + i + "");
+					Log.d("offset=" + searchresult.get_offset(), "");
 					field.setGravity(Gravity.CENTER);
 					field.setPadding(10, 5, 10, 5);
 					field.setTextSize(20);
@@ -547,7 +571,7 @@ public class ResultActivity extends Activity
 					for (int j = 0; j < showfieldmap.size(); j++)
 					{
 						TextView field1 = new TextView(ResultActivity.this);
-						Log.d("onPostExecute",showfieldmap.get(j));
+						// Log.d("onPostExecute", showfieldmap.get(j));
 						String str = record.get(showfieldmap.get(j));
 						field1.setBackgroundResource(R.drawable.tableitem);
 						if (str.toLowerCase().trim().equals("null"))
@@ -569,7 +593,7 @@ public class ResultActivity extends Activity
 				Button btnnext = (Button) findViewById(R.id.btn_next);
 
 				Button btnpre = (Button) findViewById(R.id.btn_pre);
-				if (searchresult.get_offset() <= 10)
+				if (searchresult.get_offset() == 0)
 					btnpre.setEnabled(false);
 				else
 				{
@@ -579,42 +603,12 @@ public class ResultActivity extends Activity
 					btnnext.setEnabled(false);
 				else
 					btnnext.setEnabled(true);
-				// // fill fake data
-				// for(int i=0;i<10;i++)
-				// {
-				// TableRow recordRow = new TableRow(ResultActivity.this);
-				// for(int j=0;j<showfieldmap.size();j++)
-				// {
-				// TextView field = new TextView(ResultActivity.this);
-				// field.setText("fake data");
-				// field.setGravity(Gravity.CENTER);
-				// field.setTextAppearance(ResultActivity.this,android.R.attr.textAppearanceMedium);
-				// recordRow.addView(field);
-				// }
-				// TableLayout tl=(TableLayout)findViewById(R.id.result_table);
-				// tl.addView(recordRow);
-				//
-				// }
 
-				// 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
 			{
-				// TextView tv_head = (TextView) findViewById(R.id.tv_head);
-				// m_etPassword
-				// .setError(getString(R.string.error_incorrect_password));
-				// m_etPassword.requestFocus();
+				LinearLayout ll = (LinearLayout) findViewById(R.id.ll_refresh);
+				ll.setVisibility(View.VISIBLE);
 			}
 		}
 
@@ -629,7 +623,7 @@ public class ResultActivity extends Activity
 	private class SearchResult
 	{
 		int total_count = -1;
-		int direction = 1;
+		// int direction = 1;
 		int offset = 0;
 		// int count = 0;
 		ArrayList<HashMap<String, String>> records = new ArrayList<HashMap<String, String>>();
@@ -643,6 +637,11 @@ public class ResultActivity extends Activity
 		//
 		// }
 
+		public int get_recordscount()
+		{
+			return records.size();
+		}
+
 		public HashMap<String, String> get_record(int i)
 		{
 			return records.get(i);
@@ -656,14 +655,15 @@ public class ResultActivity extends Activity
 				JSONObject objrecords = new JSONObject(jsonstr);
 				for (int i = 0; i < objrecords.length(); i++)
 				{
-					offset++;
+					// offset++;
 					JSONObject rec = objrecords.getJSONObject("record" + i);
 					Iterator<?> it = rec.keys();
 					HashMap<String, String> record = new HashMap<String, String>();
 					while (it.hasNext()) // loop for each function
 					{
 						String field_name = (String) it.next();
-						String val = rec.getString(field_name).replace("\n", "");
+						String val = rec.getString(field_name)
+								.replace("\n", "");
 						record.put(field_name, val);
 					}
 					records.add(record);
@@ -697,10 +697,10 @@ public class ResultActivity extends Activity
 			return offset;
 		}
 
-		public int get_direction()
-		{
-			return direction;
-		}
+		// public int get_direction()
+		// {
+		// return direction;
+		// }
 
 		public void set_offset(int i)
 		{
@@ -708,47 +708,9 @@ public class ResultActivity extends Activity
 
 		}
 
-		public void set_direction(int i)
-		{
-			direction = i;
-
-		}
-		// public int get_count()
-		// {
-		// return records.size();
-		// }
-
-		// public int get_fieldscount()
-		// {
-		// return fields.size();
-		// }
-
-		// private class record
-		// {
-		// HashMap<String,Object> values = ;
-		//
-		// }
-
-		// private class field
+		// public void set_direction(int i)
 		// {
-		// String name = null;
-		// String aliasname = null;
-		// String type = null;
-		//
-		// public String get_name()
-		// {
-		// return name;
-		// }
-		//
-		// public String get_aliasname()
-		// {
-		// return aliasname;
-		// }
-		//
-		// public String get_type()
-		// {
-		// return type;
-		// }
+		// direction = i;
 		//
 		// }
 

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

@@ -16,12 +16,16 @@ import com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener;
 import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
 import com.google.android.gms.maps.CameraUpdateFactory;
 import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.BitmapDescriptor;
 import com.google.android.gms.maps.model.BitmapDescriptorFactory;
 import com.google.android.gms.maps.model.CameraPosition;
 import com.google.android.gms.maps.model.LatLng;
 import com.google.android.gms.maps.model.Marker;
 import com.google.android.gms.maps.model.MarkerOptions;
 import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.drawable.Drawable;
 //import android.app.Fragment;
 //import android.app.FragmentManager;
 //import android.app.FragmentManager;
@@ -32,6 +36,7 @@ import android.os.Bundle;
 
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
+import android.util.Log;
 //import android.support.v4.app.FragmentManager;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -171,6 +176,10 @@ public class ServiceLocationFragment extends Fragment implements
 //			detail.Contact=contact;
 //			detail.Email=email;
 			marker_detail.put(markertext, detail);
+//			BitmapDescriptor bd=BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher);
+//			Drawable da=getResources().getDrawable(R.drawable.ic_launcher);
+			Bitmap bmp=BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
+			Log.d("markersize",bmp.getWidth()+","+bmp.getHeight());
 			map.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher))
 					.position(
 							new LatLng(Double.parseDouble(point[0]), Double

+ 99 - 21
Apex/src/com/usai/util/Network.java

@@ -409,6 +409,66 @@ public class Network
 
 		// return RESULT_ERROR;
 	}
+	public static String get_detail( Bundle parms)
+	{
+		String TAG = "net_dbg@get_detail";
+		parms.putString("action", "handset_search");
+		parms.putString("sessionid", ApexTrackingApplication.get_sessionid());
+		String jstr = getJson(Network.URL_REQUEST_RECORDS, parms);
+		if (jstr == null || jstr.length() <= 0)
+		{
+			Log.d(TAG, "json is wrong");
+			return null;
+		}
+		JSONObject jsobj;
+		//
+		// array = new JSONArray(json);
+		try
+		{
+			jsobj = new JSONObject(jstr);
+			if (jsobj.length() > 0)
+			{
+				if (jsobj.getInt("result") != Network.AP_USER_AUTH)
+				{
+					// session expired
+					Log.d(TAG,
+							"USER NOT AUTHORIZED CODE="
+									+ jsobj.getInt("result"));
+					return null;
+					// if (get_Auth(name, password) == RESULT_TRUE)
+					// {
+					// return get_records(name, password, parms);
+					//
+					// }
+					// else
+					// {
+					//
+					// Log.d(TAG,
+					// "USER NOT AUTHORIZED CODE="
+					// + jsobj.getInt("result"));
+					// return null;
+					// }
+				}
+				else
+				{
+					return jstr;
+				}
+			}
+			else
+			{
+				Log.d(TAG, "json is wrong");
+				return null;
+			}
+		}
+		catch (JSONException e)
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		return null;
+		
+		// return RESULT_ERROR;
+	}
 
 	public static int get_Auth(String name, String password)
 	{
@@ -497,13 +557,18 @@ public class Network
 
 				editor.putInt("AuthInfoVer", objheader.getInt("ver"));
 				JSONObject objfuncs = jsobj.getJSONObject("functions");
-				Iterator it = objfuncs.keys();
+				Iterator<?> it = objfuncs.keys();
 				db = dbUtil.OpenDB(ApexTrackingApplication.get_instance(),
 						null, true);
 				String sql = "insert into fields_info(name,aname,field_type,function_name,behavior,priority,show,user) values(?,?,?,?,?,?,?,?)";
+				String sql1 = "insert into actions_info(name,function_name,user) values(?,?,?)";
 				db.execSQL("update fields_info set abandon = 1 where user ='"
 						+ user + "'");
+				db.execSQL("update actions_info set abandon = 1 where user ='"
+						+ user + "'");
+
 				SQLiteStatement stat = db.compileStatement(sql);
+				SQLiteStatement stat1 = db.compileStatement(sql1);
 				db.beginTransaction();
 				String field_name, field_type, alias_name;
 				while (it.hasNext()) // loop for each function
@@ -515,7 +580,7 @@ public class Network
 					int behavior, priority = 999;
 					int show = 1;
 					JSONObject objbehavior = objfun.getJSONObject("search");
-					Iterator itbehavior = objbehavior.keys();
+					Iterator<?> itbehavior = objbehavior.keys();
 					behavior = BEHAVIOR_SEARCH;
 					while (itbehavior.hasNext()) // loop for search fields in
 													// certain function
@@ -551,7 +616,7 @@ public class Network
 					}
 
 					objbehavior = objfun.getJSONObject("result");
-					Iterator itresult = objbehavior.keys();
+					Iterator<?> itresult = objbehavior.keys();
 					behavior = BEHAVIOR_RESULT;
 					while (itresult.hasNext()) // loop for result fields in
 												// certain function
@@ -585,26 +650,39 @@ public class Network
 							stat.executeInsert();
 						}
 					}
-					// editor.putString(func_name, 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);
-					// }
+
+					objbehavior = objfun.getJSONObject("actions");
+					Iterator<?> itactions = objbehavior.keys();
+					// behavior = BEHAVIOR_RESULT;
+					while (itactions.hasNext()) // loop for result fields in
+												// certain function
+					{
+						String actionname = (String) itactions.next();
+						boolean b = objbehavior.getBoolean(actionname);
+						if (b == false)
+							continue;
+
+						int id = dbUtil.get_recordid(db, "actions_info",
+								"name='" + actionname + "' and function_name='"
+										+ func_name + "' and user='" + user
+										+ "'");
+						if (id >= 0) // record exist;
+						{
+							db.execSQL("update actions_info set abandon = 0 where _id ="
+									+ id);
+						}
+						else
+						{
+							stat1.bindString(1, actionname);
+							stat1.bindString(2, func_name);
+							stat1.bindString(3, user);
+							stat1.executeInsert();
+
+						}
+					}
 				}
 				db.execSQL("delete from fields_info where abandon = 1");
+				db.execSQL("delete from actions_info where abandon = 1");
 				db.setTransactionSuccessful();
 				db.endTransaction();
 				editor.commit();

+ 11 - 8
Apex/src/com/usai/util/dbUtil.java

@@ -379,6 +379,10 @@ public class dbUtil
 				+ "priority INTEGER," + "show BOOLEAN," + "abandon BOOLEAN,"
 				+ "user VARCHAR(20))");
 
+		dbHelper.addInitSQL("CREATE TABLE actions_info ("
+				+ "_id INTEGER PRIMARY KEY," + "name VARCHAR(20),"
+				+ "function_name VARCHAR(20)," + "abandon BOOLEAN,"
+				+ "user VARCHAR(20))");
 		// dbHelper.addInitSQL("create table pics (" +
 		// "_id INTEGER PRIMARY KEY,"
 		// + "picker varchar(20)," + "err_code INTEGER ,"
@@ -517,17 +521,16 @@ public class dbUtil
 				.getApplicationContext(), null, false);
 		Cursor cursor = db.query("fields_info", new String[] { "name" },
 				"function_name='" + module + "' and user='" + user
-						+ "' and behavior=" + Network.BEHAVIOR_SEARCH
-						, null, null, null,
-				null, null);
-		String ret="";
+						+ "' and behavior=" + Network.BEHAVIOR_SEARCH, null,
+				null, null, null, null);
+		String ret = "";
 		while (cursor.moveToNext())
 		{
-			ret +=cursor.getString(0);
-			ret +=",";
-			
+			ret += cursor.getString(0);
+			ret += ",";
+
 		}
-		ret = ret.substring(0,ret.length()-1);
+		ret = ret.substring(0, ret.length() - 1);
 		CloseCursor(cursor);
 		CloseDB(db);
 		return ret;